Skip to content

Commit

Permalink
Merge pull request #7 from nickel-lang/let-rec
Browse files Browse the repository at this point in the history
Add "rec" keyword for let bindings
  • Loading branch information
ErinvanderVeen authored Apr 29, 2022
2 parents ebc0a3f + 89b275a commit c4dd142
Show file tree
Hide file tree
Showing 6 changed files with 16,888 additions and 14,258 deletions.
27 changes: 27 additions & 0 deletions corpus/let-rec.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
================================================================================
let rec
================================================================================

let rec x = x in x

--------------------------------------------------------------------------------

(term
(uni_term
(let_expr
(pattern
(ident))
(term
(uni_term
(infix_expr
(applicative
(record_operand
(atom
(ident)))))))
(term
(uni_term
(infix_expr
(applicative
(record_operand
(atom
(ident))))))))))
1 change: 1 addition & 0 deletions grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ module.exports = grammar({

let_expr: $ => seq(
"let",
optional("rec"),
field("pat", $.pattern),
field("meta", optional($.annot)),
"=",
Expand Down
1 change: 1 addition & 0 deletions queries/highlights.scm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"let"
"default"
"doc"
"rec"
] @keyword

"fun" @keyword.function
Expand Down
12 changes: 12 additions & 0 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@
"type": "STRING",
"value": "let"
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "rec"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "pat",
Expand Down
4 changes: 4 additions & 0 deletions src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -1571,6 +1571,10 @@
"type": "num_literal",
"named": true
},
{
"type": "rec",
"named": false
},
{
"type": "str_esc_char",
"named": true
Expand Down
Loading

0 comments on commit c4dd142

Please sign in to comment.