reflection foundation, tuples, debug.print
This commit is contained in:
@@ -30,6 +30,9 @@ module.exports = grammar({
|
||||
[$.array_type, $.expression],
|
||||
[$.array_type, $.array_literal],
|
||||
[$.expression_statement, $.parenthesized_expression],
|
||||
[$.block, $.tuple_literal],
|
||||
[$.field_initializer, $.expression],
|
||||
[$.tuple_literal],
|
||||
],
|
||||
|
||||
rules: {
|
||||
@@ -124,8 +127,8 @@ module.exports = grammar({
|
||||
'}',
|
||||
),
|
||||
|
||||
record_field: $ => seq(
|
||||
field('name', $.identifier),
|
||||
record_field: $ => choice(
|
||||
seq(field('name', $.identifier), field('type', choice($.type, $.struct_type))),
|
||||
field('type', choice($.type, $.struct_type)),
|
||||
),
|
||||
|
||||
@@ -336,6 +339,7 @@ module.exports = grammar({
|
||||
),
|
||||
|
||||
for_statement: $ => seq(
|
||||
optional('inline'),
|
||||
'for',
|
||||
repeat($._newline),
|
||||
field('iterable', $.expression),
|
||||
@@ -393,6 +397,7 @@ module.exports = grammar({
|
||||
$.slice_expression,
|
||||
$.postfix_expression,
|
||||
$.struct_literal,
|
||||
$.tuple_literal,
|
||||
$.comptime_block,
|
||||
$.function_literal,
|
||||
$.struct_type,
|
||||
@@ -442,7 +447,7 @@ module.exports = grammar({
|
||||
field_expression: $ => prec.left(PREC.POSTFIX, seq(
|
||||
field('value', $.expression),
|
||||
'.',
|
||||
field('field', $.identifier),
|
||||
field('field', choice($.identifier, $.integer)),
|
||||
)),
|
||||
|
||||
intrinsic_call_expression: $ => prec(PREC.POSTFIX, seq(
|
||||
@@ -495,8 +500,8 @@ module.exports = grammar({
|
||||
repeat($._newline),
|
||||
seq(
|
||||
repeat($._newline),
|
||||
$.field_initializer,
|
||||
repeat(seq(repeat($._newline), ',', repeat($._newline), $.field_initializer)),
|
||||
choice($.field_initializer, $.expression),
|
||||
repeat(seq(repeat($._newline), ',', repeat($._newline), choice($.field_initializer, $.expression))),
|
||||
optional(seq(repeat($._newline), ',')),
|
||||
repeat($._newline),
|
||||
),
|
||||
@@ -509,6 +514,16 @@ module.exports = grammar({
|
||||
optional(seq('=', repeat($._newline), field('value', $.expression))),
|
||||
),
|
||||
|
||||
tuple_literal: $ => prec(1, choice(
|
||||
seq('{', repeat($._newline), '}'),
|
||||
seq(
|
||||
'{', repeat($._newline), $.expression,
|
||||
',', repeat($._newline),
|
||||
repeat(seq($.expression, ',', repeat($._newline))),
|
||||
optional($.expression), repeat($._newline), '}',
|
||||
),
|
||||
)),
|
||||
|
||||
enum_literal: $ => seq(
|
||||
'.',
|
||||
field('name', $.identifier),
|
||||
|
||||
Reference in New Issue
Block a user