slightly simplified grammar

This commit is contained in:
William Ball 2024-12-14 11:10:59 -08:00
parent 63f0f27240
commit b646790fdb
5 changed files with 1788 additions and 1976 deletions

View file

@ -46,23 +46,15 @@ module.exports = grammar({
';'
),
variable_binding : $ => seq(
'(',
repeat1(choice($.identifier, $.symbol)),
':',
field('type', $.expr),
')',
),
variable : $ => seq(
choice('variable', 'hypothesis'),
repeat1($.variable_binding),
repeat1($.param_block),
';'
),
param_block : $ => seq(
'(',
field('param', repeat1($.identifier)),
field('param', repeat1(choice($.identifier, $.symbol))),
':',
field('type', $.expr),
')'

56
src/grammar.json generated
View file

@ -116,47 +116,6 @@
}
]
},
"variable_binding": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "symbol"
}
]
}
},
{
"type": "STRING",
"value": ":"
},
{
"type": "FIELD",
"name": "type",
"content": {
"type": "SYMBOL",
"name": "expr"
}
},
{
"type": "STRING",
"value": ")"
}
]
},
"variable": {
"type": "SEQ",
"members": [
@ -177,7 +136,7 @@
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "variable_binding"
"name": "param_block"
}
},
{
@ -199,8 +158,17 @@
"content": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "identifier"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "identifier"
},
{
"type": "SYMBOL",
"name": "symbol"
}
]
}
}
},

36
src/node-types.json generated
View file

@ -359,6 +359,10 @@
{
"type": "identifier",
"named": true
},
{
"type": "symbol",
"named": true
}
]
},
@ -507,37 +511,7 @@
"required": true,
"types": [
{
"type": "variable_binding",
"named": true
}
]
}
},
{
"type": "variable_binding",
"named": true,
"fields": {
"type": {
"multiple": false,
"required": true,
"types": [
{
"type": "expr",
"named": true
}
]
}
},
"children": {
"multiple": true,
"required": true,
"types": [
{
"type": "identifier",
"named": true
},
{
"type": "symbol",
"type": "param_block",
"named": true
}
]

3652
src/parser.c generated

File diff suppressed because it is too large Load diff

View file

@ -18,7 +18,7 @@ end Test
(identifier)
(program
(variable
(variable_binding
(param_block
(identifier)
(identifier)
(identifier)
@ -30,7 +30,7 @@ end Test
(sort
(star)))))))))
(variable
(variable_binding
(param_block
(identifier)
(expr
(app_term
@ -38,7 +38,7 @@ end Test
(app
(term
(identifier)))))))
(variable_binding
(param_block
(identifier)
(expr
(app_term
@ -46,7 +46,7 @@ end Test
(app
(term
(identifier)))))))
(variable_binding
(param_block
(identifier)
(identifier)
(expr