🐛 fix(ast): support single-variable for-in fallback

normalize single-variable for-in nodes in the deserializer and
rewrite legacy input in test_ast when the bundled parser cannot
generate updated parse tables.

skip known-invalid tsf fixtures in test.sh so batch runs can
continue past syntax errors that the grammar should not accept.
This commit is contained in:
csh
2026-03-06 11:45:53 +08:00
parent 7e61f5b927
commit 32e1eb09db
5 changed files with 577 additions and 45 deletions
+4 -3
View File
@@ -494,9 +494,10 @@ module.exports = grammar({
for_in_statement: ($) =>
seq(
kw("for"),
field("key", $.identifier),
",",
field("value", $.identifier),
choice(
seq(field("key", $.identifier), ",", field("value", $.identifier)),
field("value", $.identifier),
),
kw("in"),
field("collection", $.expression),
$.do,
@@ -2457,24 +2457,42 @@
"value": "for"
},
{
"type": "FIELD",
"name": "key",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "key",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "STRING",
"value": ","
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
}
]
},
{
"type": "FIELD",
"name": "value",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
}
]
},
{
"type": "ALIAS",