support functions in let

This commit is contained in:
William Ball 2024-11-23 10:39:33 -08:00
parent 356b6600f2
commit 6e1878db5d
5 changed files with 592 additions and 557 deletions

View file

@ -38,7 +38,7 @@ module.exports = grammar({
param_block : $ => seq(
'(',
field('param', repeat($.identifier)),
field('param', repeat1($.identifier)),
':',
field('type', $.expr),
')'
@ -71,6 +71,7 @@ module.exports = grammar({
binding : $ => seq(
'(',
$.identifier,
repeat($.param_block),
':=',
$.expr,
')',

9
src/grammar.json generated
View file

@ -92,7 +92,7 @@
"type": "FIELD",
"name": "param",
"content": {
"type": "REPEAT",
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "identifier"
@ -254,6 +254,13 @@
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "REPEAT",
"content": {
"type": "SYMBOL",
"name": "param_block"
}
},
{
"type": "STRING",
"value": ":="

6
src/node-types.json generated
View file

@ -91,6 +91,10 @@
{
"type": "identifier",
"named": true
},
{
"type": "param_block",
"named": true
}
]
}
@ -215,7 +219,7 @@
"fields": {
"param": {
"multiple": true,
"required": false,
"required": true,
"types": [
{
"type": "identifier",

1116
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -4,6 +4,7 @@ Let
foo := let (x := a)
(y := x)
(f (x : A) := x)
in
x
end;
@ -30,6 +31,20 @@ foo := let (x := a)
(app
(term
(identifier))))))
(binding
(identifier)
(param_block
(identifier)
(expr
(app_term
(app
(term
(identifier))))))
(expr
(app_term
(app
(term
(identifier))))))
(expr
(app_term
(app