Skip to content

Commit

Permalink
Merge pull request #51 from jneem/let-blocks
Browse files Browse the repository at this point in the history
Support let blocks
  • Loading branch information
Erin van der Veen authored Aug 15, 2024
2 parents 5e29fda + 267cd8c commit 48cb1fc
Show file tree
Hide file tree
Showing 16 changed files with 20,344 additions and 19,751 deletions.
10 changes: 7 additions & 3 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ module.exports = grammar({
field("t2", $.term),
),

let_in_block: $ => seq(
"let",
optional("rec"),
let_binding: $ => seq(
field("pat", $.pattern),
field("meta", optional($.annot)),
"=",
field("t1", $.term),
),

let_in_block: $ => seq(
"let",
optional("rec"),
field("bindings", seq(commaSep($.let_binding), optional(","))),
"in",
),

Expand Down
93 changes: 76 additions & 17 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,25 +270,9 @@
}
]
},
"let_in_block": {
"let_binding": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "let"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "rec"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "pat",
Expand Down Expand Up @@ -324,6 +308,81 @@
"type": "SYMBOL",
"name": "term"
}
}
]
},
"let_in_block": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "let"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "rec"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "bindings",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "let_binding"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "SYMBOL",
"name": "let_binding"
}
]
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "STRING",
Expand Down
50 changes: 35 additions & 15 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -938,20 +938,30 @@
}
},
{
"type": "let_expr",
"type": "let_binding",
"named": true,
"fields": {
"binding": {
"meta": {
"multiple": false,
"required": false,
"types": [
{
"type": "annot",
"named": true
}
]
},
"pat": {
"multiple": false,
"required": true,
"types": [
{
"type": "let_in_block",
"type": "pattern",
"named": true
}
]
},
"t2": {
"t1": {
"multiple": false,
"required": true,
"types": [
Expand All @@ -964,35 +974,45 @@
}
},
{
"type": "let_in_block",
"type": "let_expr",
"named": true,
"fields": {
"meta": {
"binding": {
"multiple": false,
"required": false,
"required": true,
"types": [
{
"type": "annot",
"type": "let_in_block",
"named": true
}
]
},
"pat": {
"t2": {
"multiple": false,
"required": true,
"types": [
{
"type": "pattern",
"type": "term",
"named": true
}
]
},
"t1": {
"multiple": false,
"required": true,
}
}
},
{
"type": "let_in_block",
"named": true,
"fields": {
"bindings": {
"multiple": true,
"required": false,
"types": [
{
"type": "term",
"type": ",",
"named": false
},
{
"type": "let_binding",
"named": true
}
]
Expand Down
Loading

0 comments on commit 48cb1fc

Please sign in to comment.