Add full-width closing bracket support after asciiend

Allow ] (U+FF3D) after asciiend in ASCII content scanner.
This enables ASCII strings inside arrays with full-width brackets:
  var x = [ascii...asciiend]

The parser now correctly recognizes this as an array containing
an ASCII string, not as a syntax error.

Fixes 1 additional parsing error.
This commit is contained in:
2025-11-27 10:40:00 +01:00
parent 9a1dcb941d
commit 06e6e3b098
4 changed files with 12128 additions and 12905 deletions

View File

@@ -175,6 +175,7 @@ module.exports = grammar({
$.string, $.string,
$.boolean, $.boolean,
$.null, $.null,
$.ascii_string,
$.array, $.array,
$.member_expression, $.member_expression,
$.call_expression, $.call_expression,
@@ -186,7 +187,6 @@ module.exports = grammar({
$.parenthesized_expression, $.parenthesized_expression,
$.new_statement, $.new_statement,
$.import_expression, $.import_expression,
$.ascii_string,
$.color_code $.color_code
), ),
@@ -282,10 +282,7 @@ module.exports = grammar({
null: $ => 'null', null: $ => 'null',
ascii_string: $ => choice( ascii_string: $ => seq('ascii', $.ascii_content, 'asciiend')
seq('ascii', $.ascii_content, 'asciiend'),
seq(choice('[', ''), 'ascii', $.ascii_content, 'asciiend', choice(']', ''))
)
}, },
extras: $ => [ extras: $ => [

74
src/grammar.json generated
View File

@@ -675,6 +675,10 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "null" "name": "null"
}, },
{
"type": "SYMBOL",
"name": "ascii_string"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "array" "name": "array"
@@ -719,10 +723,6 @@
"type": "SYMBOL", "type": "SYMBOL",
"name": "import_expression" "name": "import_expression"
}, },
{
"type": "SYMBOL",
"name": "ascii_string"
},
{ {
"type": "SYMBOL", "type": "SYMBOL",
"name": "color_code" "name": "color_code"
@@ -1369,67 +1369,19 @@
"value": "null" "value": "null"
}, },
"ascii_string": { "ascii_string": {
"type": "CHOICE", "type": "SEQ",
"members": [ "members": [
{ {
"type": "SEQ", "type": "STRING",
"members": [ "value": "ascii"
{
"type": "STRING",
"value": "ascii"
},
{
"type": "SYMBOL",
"name": "ascii_content"
},
{
"type": "STRING",
"value": "asciiend"
}
]
}, },
{ {
"type": "SEQ", "type": "SYMBOL",
"members": [ "name": "ascii_content"
{ },
"type": "CHOICE", {
"members": [ "type": "STRING",
{ "value": "asciiend"
"type": "STRING",
"value": "["
},
{
"type": "STRING",
"value": ""
}
]
},
{
"type": "STRING",
"value": "ascii"
},
{
"type": "SYMBOL",
"name": "ascii_content"
},
{
"type": "STRING",
"value": "asciiend"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "]"
},
{
"type": "STRING",
"value": ""
}
]
}
]
} }
] ]
} }

24950
src/parser.c generated

File diff suppressed because it is too large Load Diff

View File

@@ -138,7 +138,7 @@ bool tree_sitter_stonescript_external_scanner_scan(void *payload, TSLexer *lexer
if (match && (lexer->lookahead == '\n' || lexer->lookahead == '\r' || if (match && (lexer->lookahead == '\n' || lexer->lookahead == '\r' ||
lexer->lookahead == ' ' || lexer->lookahead == '\t' || lexer->lookahead == ' ' || lexer->lookahead == '\t' ||
lexer->lookahead == ',' || lexer->lookahead == ')' || lexer->lookahead == ',' || lexer->lookahead == ')' ||
lexer->lookahead == ']' || lexer->lookahead == ']' || lexer->lookahead == 0xFF3D || // full-width
lexer->eof(lexer))) { lexer->eof(lexer))) {
lexer->result_symbol = ASCII_CONTENT; lexer->result_symbol = ASCII_CONTENT;
return has_content; return has_content;