Skip to content

Commit

Permalink
Merge pull request #156 from amaanq/fixes
Browse files Browse the repository at this point in the history
Some fixes
  • Loading branch information
amaanq authored Jul 24, 2023
2 parents fcd1230 + 0cc26b0 commit cc565c4
Show file tree
Hide file tree
Showing 5 changed files with 27,464 additions and 27,258 deletions.
14 changes: 7 additions & 7 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

const PREC = {
PAREN_DECLARATOR: -10,
ASSIGNMENT: -1,
CONDITIONAL: -2,
ASSIGNMENT: -2,
CONDITIONAL: -1,
DEFAULT: 0,
LOGICAL_OR: 1,
LOGICAL_AND: 2,
Expand Down Expand Up @@ -117,22 +117,22 @@ module.exports = grammar({
$.identifier,
alias($.preproc_call_expression, $.call_expression),
)),
'\n',
token.immediate(/\r?\n/),
),

preproc_def: $ => seq(
preprocessor('define'),
field('name', $.identifier),
field('value', optional($.preproc_arg)),
'\n',
token.immediate(/\r?\n/),
),

preproc_function_def: $ => seq(
preprocessor('define'),
field('name', $.identifier),
field('parameters', $.preproc_params),
field('value', optional($.preproc_arg)),
'\n',
token.immediate(/\r?\n/),
),

preproc_params: $ => seq(
Expand All @@ -142,13 +142,13 @@ module.exports = grammar({
preproc_call: $ => seq(
field('directive', $.preproc_directive),
field('argument', optional($.preproc_arg)),
'\n',
token.immediate(/\r?\n/),
),

...preprocIf('', $ => $._block_item),
...preprocIf('_in_field_declaration_list', $ => $._field_declaration_list_item),

preproc_arg: _ => token(prec(-1, /\S(.|\\\r?\n)*/)),
preproc_arg: _ => token(prec(-1, /\S([^/\n]|\\\r?\n)*/)),
preproc_directive: _ => /#[ \t]*[a-zA-Z0-9]\w*/,

_preproc_expression: $ => choice(
Expand Down
38 changes: 25 additions & 13 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,11 @@
}
},
{
"type": "STRING",
"value": "\n"
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "\\r?\\n"
}
}
]
},
Expand Down Expand Up @@ -208,8 +211,11 @@
}
},
{
"type": "STRING",
"value": "\n"
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "\\r?\\n"
}
}
]
},
Expand Down Expand Up @@ -258,8 +264,11 @@
}
},
{
"type": "STRING",
"value": "\n"
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "\\r?\\n"
}
}
]
},
Expand Down Expand Up @@ -358,8 +367,11 @@
}
},
{
"type": "STRING",
"value": "\n"
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "\\r?\\n"
}
}
]
},
Expand Down Expand Up @@ -1010,7 +1022,7 @@
"value": -1,
"content": {
"type": "PATTERN",
"value": "\\S(.|\\\\\\r?\\n)*"
"value": "\\S([^/\\n]|\\\\\\r?\\n)*"
}
}
},
Expand Down Expand Up @@ -4954,7 +4966,7 @@
},
"conditional_expression": {
"type": "PREC_RIGHT",
"value": -2,
"value": -1,
"content": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -5032,7 +5044,7 @@
},
"assignment_expression": {
"type": "PREC_RIGHT",
"value": -1,
"value": -2,
"content": {
"type": "SEQ",
"members": [
Expand Down Expand Up @@ -7779,8 +7791,8 @@
],
"PREC": {
"PAREN_DECLARATOR": -10,
"ASSIGNMENT": -1,
"CONDITIONAL": -2,
"ASSIGNMENT": -2,
"CONDITIONAL": -1,
"DEFAULT": 0,
"LOGICAL_OR": 1,
"LOGICAL_AND": 2,
Expand Down
Loading

0 comments on commit cc565c4

Please sign in to comment.