Skip to content

Commit 8ac0c52

Browse files
author
Antonio de Jesus Ochoa Solano
committed
Simplify embedded_braced_expression
1 parent b6db7cf commit 8ac0c52

20 files changed

+166012
-166151
lines changed

grammar.js

+10-24
Original file line numberDiff line numberDiff line change
@@ -146,35 +146,21 @@ const rules = {
146146
'<<<',
147147
$._heredoc_start,
148148
opt(alias($._heredoc_start_newline, '\n')),
149-
choice.rep($._heredoc_body, $.variable, $.embedded_brace_expression),
149+
choice.rep($._heredoc_body, $.variable, $.embedded_braced_expression),
150150
opt(alias($._heredoc_end_newline, '\n')),
151151
$._heredoc_end,
152152
),
153153

154-
embedded_brace_expression: $ => seq($._embedded_brace_expression, '}'),
155-
156-
_embedded_brace_expression: $ =>
157-
choice(
158-
alias(token(seq('{$', identifier)), $.variable),
159-
alias($._embedded_brace_call_expression, $.call_expression),
160-
alias($._embedded_brace_subscript_expression, $.subscript_expression),
161-
alias($._embedded_brace_selection_expression, $.selection_expression),
162-
),
163-
164-
_embedded_brace_call_expression: $ =>
165-
seq($._embedded_brace_expression, $.arguments),
166-
167-
_embedded_brace_subscript_expression: $ =>
168-
seq($._embedded_brace_expression, '[', opt($._expression), ']'),
169-
170-
_embedded_brace_selection_expression: $ =>
171-
prec(
172-
-1,
173-
seq(
174-
$._embedded_brace_expression,
175-
field('selection_operator', choice('?->', '->')),
176-
$._variablish,
154+
embedded_braced_expression: $ =>
155+
seq(
156+
'{',
157+
choice(
158+
$.variable,
159+
$.call_expression,
160+
$.subscript_expression,
161+
$.selection_expression,
177162
),
163+
'}',
178164
),
179165

180166
braced_expression: $ => seq('{', $._expression, '}'),

src/grammar.json

+15-123
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@
415415
},
416416
{
417417
"type": "SYMBOL",
418-
"name": "embedded_brace_expression"
418+
"name": "embedded_braced_expression"
419419
}
420420
]
421421
}
@@ -443,148 +443,40 @@
443443
}
444444
]
445445
},
446-
"embedded_brace_expression": {
446+
"embedded_braced_expression": {
447447
"type": "SEQ",
448448
"members": [
449-
{
450-
"type": "SYMBOL",
451-
"name": "_embedded_brace_expression"
452-
},
453449
{
454450
"type": "STRING",
455-
"value": "}"
456-
}
457-
]
458-
},
459-
"_embedded_brace_expression": {
460-
"type": "CHOICE",
461-
"members": [
462-
{
463-
"type": "ALIAS",
464-
"content": {
465-
"type": "TOKEN",
466-
"content": {
467-
"type": "SEQ",
468-
"members": [
469-
{
470-
"type": "STRING",
471-
"value": "{$"
472-
},
473-
{
474-
"type": "PATTERN",
475-
"value": "[a-zA-Z_\\x80-\\xff][a-zA-Z0-9_\\x80-\\xff]*"
476-
}
477-
]
478-
}
479-
},
480-
"named": true,
481-
"value": "variable"
482-
},
483-
{
484-
"type": "ALIAS",
485-
"content": {
486-
"type": "SYMBOL",
487-
"name": "_embedded_brace_call_expression"
488-
},
489-
"named": true,
490-
"value": "call_expression"
491-
},
492-
{
493-
"type": "ALIAS",
494-
"content": {
495-
"type": "SYMBOL",
496-
"name": "_embedded_brace_subscript_expression"
497-
},
498-
"named": true,
499-
"value": "subscript_expression"
500-
},
501-
{
502-
"type": "ALIAS",
503-
"content": {
504-
"type": "SYMBOL",
505-
"name": "_embedded_brace_selection_expression"
506-
},
507-
"named": true,
508-
"value": "selection_expression"
509-
}
510-
]
511-
},
512-
"_embedded_brace_call_expression": {
513-
"type": "SEQ",
514-
"members": [
515-
{
516-
"type": "SYMBOL",
517-
"name": "_embedded_brace_expression"
518-
},
519-
{
520-
"type": "SYMBOL",
521-
"name": "arguments"
522-
}
523-
]
524-
},
525-
"_embedded_brace_subscript_expression": {
526-
"type": "SEQ",
527-
"members": [
528-
{
529-
"type": "SYMBOL",
530-
"name": "_embedded_brace_expression"
531-
},
532-
{
533-
"type": "STRING",
534-
"value": "["
451+
"value": "{"
535452
},
536453
{
537454
"type": "CHOICE",
538455
"members": [
539456
{
540457
"type": "SYMBOL",
541-
"name": "_expression"
458+
"name": "variable"
542459
},
543460
{
544-
"type": "BLANK"
461+
"type": "SYMBOL",
462+
"name": "call_expression"
463+
},
464+
{
465+
"type": "SYMBOL",
466+
"name": "subscript_expression"
467+
},
468+
{
469+
"type": "SYMBOL",
470+
"name": "selection_expression"
545471
}
546472
]
547473
},
548474
{
549475
"type": "STRING",
550-
"value": "]"
476+
"value": "}"
551477
}
552478
]
553479
},
554-
"_embedded_brace_selection_expression": {
555-
"type": "PREC",
556-
"value": -1,
557-
"content": {
558-
"type": "SEQ",
559-
"members": [
560-
{
561-
"type": "SYMBOL",
562-
"name": "_embedded_brace_expression"
563-
},
564-
{
565-
"type": "FIELD",
566-
"name": "selection_operator",
567-
"content": {
568-
"type": "CHOICE",
569-
"members": [
570-
{
571-
"type": "STRING",
572-
"value": "?->"
573-
},
574-
{
575-
"type": "STRING",
576-
"value": "->"
577-
}
578-
]
579-
}
580-
},
581-
{
582-
"type": "SYMBOL",
583-
"name": "_variablish"
584-
}
585-
]
586-
}
587-
},
588480
"braced_expression": {
589481
"type": "SEQ",
590482
"members": [

src/node-types.json

+7-23
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@
800800
"fields": {
801801
"function": {
802802
"multiple": false,
803-
"required": false,
803+
"required": true,
804804
"types": [
805805
{
806806
"type": "_expression",
@@ -841,25 +841,9 @@
841841
"type": "arguments",
842842
"named": true
843843
},
844-
{
845-
"type": "call_expression",
846-
"named": true
847-
},
848-
{
849-
"type": "selection_expression",
850-
"named": true
851-
},
852-
{
853-
"type": "subscript_expression",
854-
"named": true
855-
},
856844
{
857845
"type": "type_arguments",
858846
"named": true
859-
},
860-
{
861-
"type": "variable",
862-
"named": true
863847
}
864848
]
865849
}
@@ -1207,7 +1191,7 @@
12071191
}
12081192
},
12091193
{
1210-
"type": "embedded_brace_expression",
1194+
"type": "embedded_braced_expression",
12111195
"named": true,
12121196
"fields": {},
12131197
"children": {
@@ -1695,7 +1679,7 @@
16951679
"required": false,
16961680
"types": [
16971681
{
1698-
"type": "embedded_brace_expression",
1682+
"type": "embedded_braced_expression",
16991683
"named": true
17001684
},
17011685
{
@@ -4198,11 +4182,11 @@
41984182
},
41994183
{
42004184
"type": "float",
4201-
"named": false
4185+
"named": true
42024186
},
42034187
{
42044188
"type": "float",
4205-
"named": true
4189+
"named": false
42064190
},
42074191
{
42084192
"type": "for",
@@ -4370,11 +4354,11 @@
43704354
},
43714355
{
43724356
"type": "string",
4373-
"named": true
4357+
"named": false
43744358
},
43754359
{
43764360
"type": "string",
4377-
"named": false
4361+
"named": true
43784362
},
43794363
{
43804364
"type": "super",

0 commit comments

Comments
 (0)