operator sections
This commit is contained in:
parent
4131069cd4
commit
483fa6ec49
6 changed files with 4345 additions and 4050 deletions
23
grammar.js
23
grammar.js
|
|
@ -46,15 +46,17 @@ module.exports = grammar({
|
|||
';'
|
||||
),
|
||||
|
||||
variable_binding : $ => seq(
|
||||
'(',
|
||||
repeat1(choice($.identifier, $.symbol)),
|
||||
':',
|
||||
field('type', $.expr),
|
||||
')',
|
||||
),
|
||||
|
||||
variable : $ => seq(
|
||||
choice('variable', 'hypothesis'),
|
||||
repeat1(seq(
|
||||
'(',
|
||||
repeat1(choice($.identifier, $.symbol)),
|
||||
':',
|
||||
field('type', $.expr),
|
||||
')'
|
||||
)),
|
||||
repeat1($.variable_binding),
|
||||
';'
|
||||
),
|
||||
|
||||
|
|
@ -86,9 +88,16 @@ module.exports = grammar({
|
|||
$.expr,
|
||||
),
|
||||
|
||||
op_section : $ => seq(
|
||||
'(',
|
||||
$.symbol,
|
||||
')',
|
||||
),
|
||||
|
||||
term : $ => choice(
|
||||
$.identifier,
|
||||
$.sort,
|
||||
$.op_section,
|
||||
seq('(', $.expr, ')'),
|
||||
),
|
||||
|
||||
|
|
|
|||
103
src/grammar.json
generated
103
src/grammar.json
generated
|
|
@ -116,6 +116,47 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"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": [
|
||||
|
|
@ -135,45 +176,8 @@
|
|||
{
|
||||
"type": "REPEAT1",
|
||||
"content": {
|
||||
"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": ")"
|
||||
}
|
||||
]
|
||||
"type": "SYMBOL",
|
||||
"name": "variable_binding"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -360,6 +364,23 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"op_section": {
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": "("
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "symbol"
|
||||
},
|
||||
{
|
||||
"type": "STRING",
|
||||
"value": ")"
|
||||
}
|
||||
]
|
||||
},
|
||||
"term": {
|
||||
"type": "CHOICE",
|
||||
"members": [
|
||||
|
|
@ -371,6 +392,10 @@
|
|||
"type": "SYMBOL",
|
||||
"name": "sort"
|
||||
},
|
||||
{
|
||||
"type": "SYMBOL",
|
||||
"name": "op_section"
|
||||
},
|
||||
{
|
||||
"type": "SEQ",
|
||||
"members": [
|
||||
|
|
|
|||
36
src/node-types.json
generated
36
src/node-types.json
generated
|
|
@ -278,6 +278,21 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "op_section",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "symbol",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "pabs",
|
||||
"named": true,
|
||||
|
|
@ -440,6 +455,10 @@
|
|||
"type": "identifier",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "op_section",
|
||||
"named": true
|
||||
},
|
||||
{
|
||||
"type": "sort",
|
||||
"named": true
|
||||
|
|
@ -450,9 +469,24 @@
|
|||
{
|
||||
"type": "variable",
|
||||
"named": true,
|
||||
"fields": {},
|
||||
"children": {
|
||||
"multiple": true,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
"type": "variable_binding",
|
||||
"named": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "variable_binding",
|
||||
"named": true,
|
||||
"fields": {
|
||||
"type": {
|
||||
"multiple": true,
|
||||
"multiple": false,
|
||||
"required": true,
|
||||
"types": [
|
||||
{
|
||||
|
|
|
|||
8143
src/parser.c
generated
8143
src/parser.c
generated
File diff suppressed because it is too large
Load diff
22
test/corpus/op_section.txt
Normal file
22
test/corpus/op_section.txt
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
=================
|
||||
Operator Sections
|
||||
=================
|
||||
|
||||
def foo := (+) one two;
|
||||
|
||||
---
|
||||
|
||||
(program
|
||||
(definition
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(op_section
|
||||
(symbol)))
|
||||
(term
|
||||
(identifier))
|
||||
(term
|
||||
(identifier))))))))
|
||||
|
|
@ -18,39 +18,43 @@ end Test
|
|||
(identifier)
|
||||
(program
|
||||
(variable
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(sort
|
||||
(star))))))))
|
||||
(variable_binding
|
||||
(identifier)
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(sort
|
||||
(star)))))))))
|
||||
(variable
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(identifier))))))
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(identifier))))))
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(identifier)))))))
|
||||
(variable_binding
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(identifier)))))))
|
||||
(variable_binding
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(identifier)))))))
|
||||
(variable_binding
|
||||
(identifier)
|
||||
(identifier)
|
||||
(expr
|
||||
(app_term
|
||||
(binex
|
||||
(app
|
||||
(term
|
||||
(identifier))))))))
|
||||
(section
|
||||
(identifier)
|
||||
(program
|
||||
|
|
|
|||
Loading…
Reference in a new issue