Give the language service a keyword for every construct - #199
Merged
Merged
Conversation
The language service and the compiler are two descriptions of one grammar, and nothing kept them honest. Eight constructs the parsers dispatch on had no keyword entry at all - capture, projection, reducer, contribute, dialog, form, theme and ui - so they got neither syntax highlighting nor completion. Absent highlighting reads as "this construct is wrong", which is the worst signal to give someone about something that compiles, and it landed hardest on the UI-composition constructs a newcomer is least sure of. Add all eight to constructKeywords, and `profile` to clauseKeywords so `ui profile` reads the way `screen template` already does. A construct keyword also ends an indented sub-language block, which is the correct behavior for each of these. Add a specification that derives the dispatched set from ScreenplayParser and SliceParser and fails when this list has drifted from it, naming the missing constructs and the file to fix. It asserts both sets are non-empty first, so a moved file or a changed `case` shape cannot turn it into a comparison of nothing against nothing. The specification lives in the C# suite rather than beside the language service because `dotnet-build.yml` is the only workflow that runs tests on a pull request; a vitest guard here would never have run. Fixes #198
The EBNF said things the compiler does not enforce, so a reader working from it would avoid syntax that is perfectly valid: - `EveryBlock` allowed only `no automap`, though `from-every.md` shows a bare `automap` in an example and `ParseMappingBlock` accepts both. - `CompositeKeyDecl` wrote the braces as required. A composite key with and without them both compile clean. - `DollarExpr` omitted `$causedBy`, which `ExpressionParser` resolves and `keys.md` uses in a worked example. Verified by compiling each form rather than by reading the parser.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed
capture,projection,reducer,contribute,dialog,form,themeanduihad no keyword entry, so they appeared unrecognized in the editor despite compiling (Language service misses six host constructs the compiler accepts #198)everytakes a bareautomap, composite-key braces are optional, and$causedByis a valid expression root