Skip to content

Refactor/better parsing#30

Merged
devoreofox merged 5 commits into
mainfrom
refactor/betterParsing
Jul 12, 2026
Merged

Refactor/better parsing#30
devoreofox merged 5 commits into
mainfrom
refactor/betterParsing

Conversation

@devoreofox

Copy link
Copy Markdown
Owner

Brace conditionals + block-tree rewrite (v2.0.0.0)

Replaces the old :if/:else/:endif sigil conditionals with brace blocks and reworks the execution model to match. This is a breaking syntax change (existing aliases are migrated automatically on load), so it bumps to 2.0.0.0.

Syntax

  • Conditionals are now if (condition) {}, with else { and else if (condition) { on their own lines (Allman style).
  • New else if for chained conditions (first true branch wins), and a new :return statement that halts the whole alias (early exit / guard).
  • :set/:wait/:until stay as : statements. The rule is now: sigil = single-line statement, braces = block.

Architecture

  • New BlockParser parses an alias into a small node tree (LineNode / IfNode / Branch) and returns structural Diagnostics (unclosed/extra braces, orphan else, bad conditions) with line numbers.
  • CommandHandler.ExecuteAsync parses to the tree and walks it recursively instead of the old streaming BlockInterpreter stack. The active-branch bookkeeping is gone (only taken branches are visited); :return unwinds the recursion.
  • BlockInterpreter is reduced to static line helpers; the If/Else/EndIf BlockKind cases and the instance stack + Block class are removed. Condition parsing is non-throwing throughout (Condition.TryParse).

Editor / validation

  • ValidateBlocks now delegates to BlockParser, so brace/paren/condition errors surface in the editor.
  • New trigger validation (empty trigger, spaces, slashes, reserved names).
  • Errors render as editor error markers (line highlight + hover tooltip) driven by the diagnostics; the panel above the editor now shows only the line-less ones (trigger, cycle).
  • Highlighter colors if/else if/else/:return, reds bad conditions and malformed brace heads, and leaves the braces and parens uncolored.
  • List view removed — the syntax-highlighted multiline editor is the only editor now (the MultilineCommands toggle and CommandEntry.Delete go with it). DalamudTextEdit submodule bumped for Tab / Shift+Tab indent and dedent.

Migration (config v2 → v3)

  • Rewrites :if Xif (X) {, :else} + else {, :endif}, wrapping conditions in parens and re-indenting by nesting depth. A backup is saved first (Silkstring.v2.backup.json). Only touches aliases containing the old sigils; brace aliases are left untouched, so it's safe to re-run.

Tests

  • New BlockParserTests (tree shapes + every diagnostic) and ConfigMigratorTests (if/else/endif, nested, passthrough). AliasValidatorTests and BlockInterpreterTests updated for the new syntax and trigger checks.

Docs

  • CHANGELOG v2.0.0.0, README (conditionals, editor, settings), and the Help window's Conditionals and Editor tabs all updated to the brace syntax.

@devoreofox
devoreofox merged commit b2268eb into main Jul 12, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant