Skip to content

Commit

Permalink
parser: parse integer constants + allow constant inside include
Browse files Browse the repository at this point in the history
  • Loading branch information
jkbz64 committed Jan 26, 2024
1 parent 04f83a1 commit d22a13b
Show file tree
Hide file tree
Showing 4 changed files with 53,748 additions and 53,267 deletions.
6 changes: 4 additions & 2 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ module.exports = grammar({

file_name: ($) => /[A-z-_|0-9|\/]+\.[i]/i,
comment: ($) => seq("/*", /[^*]*\*+([^/*][^*]*\*+)*/, "/"),
constant: ($) => seq("{", "&", $.identifier, "}"),
constant: ($) =>
seq("{", optional("&"), choice($.identifier, $._integer_literal), "}"),

identifier: ($) => /[A-z_]{1}[A-z-_|0-9]*/i,
qualified_name: ($) =>
Expand Down Expand Up @@ -180,7 +181,8 @@ module.exports = grammar({
field("value", $._expression)
),
field("name", $.identifier),
field("value", $.double_quoted_string)
field("value", $.double_quoted_string),
$.constant
),
include: ($) =>
seq("{", $.file_name, optional(repeat($.include_argument)), "}"),
Expand Down
29 changes: 25 additions & 4 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,29 @@
"value": "{"
},
{
"type": "STRING",
"value": "&"
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "&"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "identifier"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "_integer_literal"
}
]
},
{
"type": "STRING",
Expand Down Expand Up @@ -1081,6 +1098,10 @@
"type": "SYMBOL",
"name": "double_quoted_string"
}
},
{
"type": "SYMBOL",
"name": "constant"
}
]
},
Expand Down
12 changes: 11 additions & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@
"fields": {},
"children": {
"multiple": false,
"required": true,
"required": false,
"types": [
{
"type": "identifier",
Expand Down Expand Up @@ -1570,6 +1570,16 @@
}
]
}
},
"children": {
"multiple": false,
"required": false,
"types": [
{
"type": "constant",
"named": true
}
]
}
},
{
Expand Down
Loading

0 comments on commit d22a13b

Please sign in to comment.