Skip to content

Commit

Permalink
fix: properly suffix elifdef
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonspark authored Jan 26, 2024
1 parent 34f4c7e commit ecdd500
Show file tree
Hide file tree
Showing 4 changed files with 65,784 additions and 65,407 deletions.
13 changes: 12 additions & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1340,6 +1340,17 @@ function preprocIf(suffix, content, precedence = 0) {
);
}

/**
*
* @param {GrammarSymbols<string>} $
*
* @return {AliasRule | SymbolRule<string>}
*
*/
function elifBlock($) {
return suffix ? alias($['preproc_elifdef' + suffix], $.preproc_elifdef) : $.preproc_elifdef;
}

return {
['preproc_if' + suffix]: $ => prec(precedence, seq(
preprocessor('if'),
Expand All @@ -1354,7 +1365,7 @@ function preprocIf(suffix, content, precedence = 0) {
choice(preprocessor('ifdef'), preprocessor('ifndef')),
field('name', $.identifier),
repeat(content($)),
field('alternative', optional(choice(elseBlock($), $.preproc_elifdef))),
field('alternative', optional(choice(elseBlock($), elifBlock($)))),
preprocessor('endif'),
)),

Expand Down
27 changes: 21 additions & 6 deletions src/grammar.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/node-types.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ecdd500

Please sign in to comment.