Skip to content

Commit

Permalink
refactor: states count reduction for val_table
Browse files Browse the repository at this point in the history
  • Loading branch information
blindFS committed Feb 22, 2025
1 parent ba6db53 commit d423d29
Show file tree
Hide file tree
Showing 3 changed files with 255,393 additions and 277,161 deletions.
13 changes: 9 additions & 4 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = grammar({
[$.ctrl_if_parenthesized],
[$.ctrl_try_parenthesized],
[$.expr_binary_parenthesized],
[$.list_body, $.val_table],
[$.list_body, $._table_head],
[$.parameter, $.param_type, $.param_value],
[$.pipeline],
[$.pipeline_parenthesized],
Expand All @@ -54,7 +54,7 @@ module.exports = grammar({

nu_script: ($) => seq(optional($.shebang), optional($._block_body)),

shebang: (_$) => seq(repeat(_$._newline), "#!", /.*\r?\n?/),
shebang: ($) => seq(repeat($._newline), "#!", /.*\r?\n?/),

...block_body_rules(),

Expand Down Expand Up @@ -1180,12 +1180,17 @@ module.exports = grammar({
_table_head_separator: (_$) =>
token(prec(PREC().higher, seq(/\s*/, PUNC().semicolon))),

val_table: ($) =>
_table_head: ($) =>
seq(
BRACK().open_brack,
repeat($._newline),
field("head", $.val_list),
alias($._table_head_separator, PUNC().semicolon),
),

val_table: ($) =>
seq(
BRACK().open_brack,
$._table_head,
optional(
general_body_rules("row", $.val_list, $._entry_separator, $._newline),
),
Expand Down
21 changes: 15 additions & 6 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -14796,13 +14796,9 @@
}
}
},
"val_table": {
"_table_head": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "REPEAT",
"content": {
Expand All @@ -14826,6 +14822,19 @@
},
"named": false,
"value": ";"
}
]
},
"val_table": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "SYMBOL",
"name": "_table_head"
},
{
"type": "CHOICE",
Expand Down Expand Up @@ -16600,7 +16609,7 @@
],
[
"list_body",
"val_table"
"_table_head"
],
[
"parameter",
Expand Down
Loading

0 comments on commit d423d29

Please sign in to comment.