Skip to content
This repository was archived by the owner on Oct 20, 2022. It is now read-only.

Commit d3c21ba

Browse files
committed
grammar: support record field access
1 parent 9b3149b commit d3c21ba

File tree

5 files changed

+11275
-10785
lines changed

5 files changed

+11275
-10785
lines changed

grammar.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ module.exports = grammar({
179179
choice(
180180
$.expr_map_update,
181181
$.expr_record_update,
182+
$.expr_record_access,
182183
$.expr_try,
183184
$.expr_catch,
184185
$.expr_throw,
@@ -202,6 +203,12 @@ module.exports = grammar({
202203
expr_map_update: ($) =>
203204
prec.left(PREC.EXPR_MAP_UPDATE, seq($.expression, $.map)),
204205

206+
expr_record_access: ($) =>
207+
prec.left(
208+
PREC.EXPR_MAP_UPDATE,
209+
seq($.expression, HASH, $.atom, DOT, $.atom)
210+
),
211+
205212
expr_record_update: ($) =>
206213
prec.left(PREC.EXPR_MAP_UPDATE, seq($.expression, $.record)),
207214

src/grammar.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,10 @@
513513
"type": "SYMBOL",
514514
"name": "expr_record_update"
515515
},
516+
{
517+
"type": "SYMBOL",
518+
"name": "expr_record_access"
519+
},
516520
{
517521
"type": "SYMBOL",
518522
"name": "expr_try"
@@ -604,6 +608,35 @@
604608
]
605609
}
606610
},
611+
"expr_record_access": {
612+
"type": "PREC_LEFT",
613+
"value": 9,
614+
"content": {
615+
"type": "SEQ",
616+
"members": [
617+
{
618+
"type": "SYMBOL",
619+
"name": "expression"
620+
},
621+
{
622+
"type": "STRING",
623+
"value": "#"
624+
},
625+
{
626+
"type": "SYMBOL",
627+
"name": "atom"
628+
},
629+
{
630+
"type": "STRING",
631+
"value": "."
632+
},
633+
{
634+
"type": "SYMBOL",
635+
"name": "atom"
636+
}
637+
]
638+
}
639+
},
607640
"expr_record_update": {
608641
"type": "PREC_LEFT",
609642
"value": 9,

src/node-types.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,25 @@
736736
]
737737
}
738738
},
739+
{
740+
"type": "expr_record_access",
741+
"named": true,
742+
"fields": {},
743+
"children": {
744+
"multiple": true,
745+
"required": true,
746+
"types": [
747+
{
748+
"type": "atom",
749+
"named": true
750+
},
751+
{
752+
"type": "expression",
753+
"named": true
754+
}
755+
]
756+
}
757+
},
739758
{
740759
"type": "expr_record_update",
741760
"named": true,
@@ -890,6 +909,10 @@
890909
"type": "expr_receive",
891910
"named": true
892911
},
912+
{
913+
"type": "expr_record_access",
914+
"named": true
915+
},
893916
{
894917
"type": "expr_record_update",
895918
"named": true

0 commit comments

Comments
 (0)