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:
@@ -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
74
src/grammar.json
generated
@@ -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
24950
src/parser.c
generated
File diff suppressed because it is too large
Load Diff
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user