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

74
src/grammar.json generated
View File

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

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' ||
lexer->lookahead == ' ' || lexer->lookahead == '\t' ||
lexer->lookahead == ',' || lexer->lookahead == ')' ||
lexer->lookahead == ']' ||
lexer->lookahead == ']' || lexer->lookahead == 0xFF3D || // full-width
lexer->eof(lexer))) {
lexer->result_symbol = ASCII_CONTENT;
return has_content;