feat: add support for fullwidth Unicode, multiline arrays, and ASCII blocks

- Add fullwidth brackets [] (U+FF3B, U+FF3D) support
- Add fullwidth quotes " (U+FF02) support
- Fix multiline arrays with newlines between elements
- Fix line continuation with CRLF (^)
- Enable ASCII block syntax (ascii...asciiend and [ascii...asciiend])
- Update conflicts to resolve ambiguities

Fixed 51 parsing errors (253 -> 202 errors)
This commit is contained in:
2025-11-26 23:04:03 +01:00
parent b746fcec44
commit 99dadd9ca7
5 changed files with 16668 additions and 12483 deletions

View File

@@ -142,8 +142,7 @@ module.exports = grammar({
print_command: $ => prec.right(seq(
choice('>', '>o', '>h', '>`', '>c', '>f'),
optional($.print_args),
repeat($.print_continuation)
optional($.print_args)
)),
// Print specific helpers
@@ -165,14 +164,6 @@ module.exports = grammar({
'@'
),
print_continuation: $ => prec.right(seq(
'^',
repeat(choice(
/[^@\r\n]+/,
$.interpolation
))
)),
color_code: $ => /#[a-zA-Z0-9]+/,
// Expressions
@@ -195,7 +186,7 @@ module.exports = grammar({
$.assignment_expression,
$.parenthesized_expression,
$.new_statement,
// $.ascii_string,
$.ascii_string,
$.color_code
),
@@ -218,9 +209,9 @@ module.exports = grammar({
index_expression: $ => prec.left(13, seq(
$._expression,
'[',
choice('[', ''),
$._expression,
']'
choice(']', '')
)),
unary_expression: $ => prec.right(12, seq(
@@ -264,14 +255,22 @@ module.exports = grammar({
// Arrays
array: $ => seq(
'[',
optional($.array_elements),
']'
choice('[', ''),
repeat($._newline),
optional(seq(
$.array_elements,
repeat($._newline)
)),
choice(']', '')
),
array_elements: $ => seq(
$._expression,
repeat(seq(',', $._expression)),
repeat(seq(
',',
repeat($._newline),
$._expression
)),
optional(',')
),
@@ -282,21 +281,24 @@ module.exports = grammar({
float: $ => /\d+\.\d+/,
string: $ => seq('"', repeat(choice(/[^"\\]/, /\\./)), '"'),
string: $ => choice(
seq('"', repeat(choice(/[^"\\]/, /\\./)), '"'),
seq('', repeat(choice(/[^\\]/, /\\./)), '')
),
boolean: $ => choice('true', 'false'),
null: $ => 'null',
// ascii_string: $ => seq(
// 'ascii',
// $.ascii_content,
// 'asciiend'
// )
ascii_string: $ => choice(
seq('ascii', $.ascii_content, 'asciiend'),
seq(choice('[', ''), 'ascii', $.ascii_content, 'asciiend', choice(']', ''))
)
},
extras: $ => [
/[ \t\r\f]/,
/[\r\n]\^/,
/\r?\n[ \t]*\^/,
$.comment,
$.block_comment
],
@@ -304,7 +306,8 @@ module.exports = grammar({
externals: $ => [
$._newline,
$._indent,
$._dedent
$._dedent,
$.ascii_content
],
word: $ => $.identifier,
@@ -315,7 +318,9 @@ module.exports = grammar({
[$.command],
[$._statement, $._expression], // new_statement can be both
[$.binary_expression, $.assignment_expression], // = operator ambiguity
[$.command, $._expression] // * operator ambiguity
[$.command, $._expression], // * operator ambiguity
[$.array_elements],
[$.ascii_string]
]
});