added let expressions
This commit is contained in:
parent
158683891c
commit
356b6600f2
5 changed files with 1921 additions and 924 deletions
17
grammar.js
17
grammar.js
|
|
@ -68,6 +68,22 @@ module.exports = grammar({
|
||||||
seq('(', $.expr, ')'),
|
seq('(', $.expr, ')'),
|
||||||
),
|
),
|
||||||
|
|
||||||
|
binding : $ => seq(
|
||||||
|
'(',
|
||||||
|
$.identifier,
|
||||||
|
':=',
|
||||||
|
$.expr,
|
||||||
|
')',
|
||||||
|
),
|
||||||
|
|
||||||
|
let : $ => seq(
|
||||||
|
'let',
|
||||||
|
repeat1($.binding),
|
||||||
|
'in',
|
||||||
|
$.expr,
|
||||||
|
'end',
|
||||||
|
),
|
||||||
|
|
||||||
app : $ => repeat1($.term),
|
app : $ => repeat1($.term),
|
||||||
|
|
||||||
axiom : $ => 'axiom',
|
axiom : $ => 'axiom',
|
||||||
|
|
@ -81,6 +97,7 @@ module.exports = grammar({
|
||||||
app_term : $ => choice(
|
app_term : $ => choice(
|
||||||
$.labs,
|
$.labs,
|
||||||
$.pabs,
|
$.pabs,
|
||||||
|
$.let,
|
||||||
$.app,
|
$.app,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|
|
||||||
57
src/grammar.json
generated
57
src/grammar.json
generated
|
|
@ -243,6 +243,59 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"binding": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "("
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "identifier"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ":="
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": ")"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"let": {
|
||||||
|
"type": "SEQ",
|
||||||
|
"members": [
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "let"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "REPEAT1",
|
||||||
|
"content": {
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "binding"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "in"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "expr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "STRING",
|
||||||
|
"value": "end"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"app": {
|
"app": {
|
||||||
"type": "REPEAT1",
|
"type": "REPEAT1",
|
||||||
"content": {
|
"content": {
|
||||||
|
|
@ -295,6 +348,10 @@
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "pabs"
|
"name": "pabs"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "SYMBOL",
|
||||||
|
"name": "let"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "SYMBOL",
|
"type": "SYMBOL",
|
||||||
"name": "app"
|
"name": "app"
|
||||||
|
|
|
||||||
54
src/node-types.json
generated
54
src/node-types.json
generated
|
|
@ -30,6 +30,10 @@
|
||||||
"type": "labs",
|
"type": "labs",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "let",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "pabs",
|
"type": "pabs",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
@ -72,6 +76,25 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "binding",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "expr",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "identifier",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "definition",
|
"type": "definition",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -148,6 +171,25 @@
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "let",
|
||||||
|
"named": true,
|
||||||
|
"fields": {},
|
||||||
|
"children": {
|
||||||
|
"multiple": true,
|
||||||
|
"required": true,
|
||||||
|
"types": [
|
||||||
|
{
|
||||||
|
"type": "binding",
|
||||||
|
"named": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "expr",
|
||||||
|
"named": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "pabs",
|
"type": "pabs",
|
||||||
"named": true,
|
"named": true,
|
||||||
|
|
@ -315,6 +357,10 @@
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "end",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "forall",
|
"type": "forall",
|
||||||
"named": false
|
"named": false
|
||||||
|
|
@ -327,6 +373,14 @@
|
||||||
"type": "identifier",
|
"type": "identifier",
|
||||||
"named": true
|
"named": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "in",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "let",
|
||||||
|
"named": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "post_command",
|
"type": "post_command",
|
||||||
"named": true
|
"named": true
|
||||||
|
|
|
||||||
2680
src/parser.c
generated
2680
src/parser.c
generated
File diff suppressed because it is too large
Load diff
37
test/corpus/let.txt
Normal file
37
test/corpus/let.txt
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
===
|
||||||
|
Let
|
||||||
|
===
|
||||||
|
|
||||||
|
foo := let (x := a)
|
||||||
|
(y := x)
|
||||||
|
in
|
||||||
|
x
|
||||||
|
end;
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
(program
|
||||||
|
(definition
|
||||||
|
(identifier)
|
||||||
|
(expr
|
||||||
|
(app_term
|
||||||
|
(let
|
||||||
|
(binding
|
||||||
|
(identifier)
|
||||||
|
(expr
|
||||||
|
(app_term
|
||||||
|
(app
|
||||||
|
(term
|
||||||
|
(identifier))))))
|
||||||
|
(binding
|
||||||
|
(identifier)
|
||||||
|
(expr
|
||||||
|
(app_term
|
||||||
|
(app
|
||||||
|
(term
|
||||||
|
(identifier))))))
|
||||||
|
(expr
|
||||||
|
(app_term
|
||||||
|
(app
|
||||||
|
(term
|
||||||
|
(identifier))))))))))
|
||||||
Loading…
Reference in a new issue