349 lines
6.3 KiB
JSON
349 lines
6.3 KiB
JSON
|
|
{
|
||
|
|
"$schema": "https://tree-sitter.github.io/tree-sitter/assets/schemas/grammar.schema.json",
|
||
|
|
"name": "perga",
|
||
|
|
"rules": {
|
||
|
|
"program": {
|
||
|
|
"type": "REPEAT",
|
||
|
|
"content": {
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "definition"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "comment"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"identifier": {
|
||
|
|
"type": "PATTERN",
|
||
|
|
"value": "[a-zA-Z_]\\w*"
|
||
|
|
},
|
||
|
|
"comment": {
|
||
|
|
"type": "TOKEN",
|
||
|
|
"content": {
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "--"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "PATTERN",
|
||
|
|
"value": ".*"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"param_block": {
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "("
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "REPEAT",
|
||
|
|
"content": {
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "identifier"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": ":"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "expr"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": ")"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"star": {
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "*"
|
||
|
|
},
|
||
|
|
"square": {
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "□"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "[]"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"lambda": {
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "λ"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "fun"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"pi": {
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "∏"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "forall"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"labs": {
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "lambda"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "REPEAT1",
|
||
|
|
"content": {
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "param_block"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "=>"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "⇒"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "expr"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"pabs": {
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "pi"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "REPEAT1",
|
||
|
|
"content": {
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "param_block"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": ","
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "expr"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"term": {
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "identifier"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "star"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "square"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "("
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "expr"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": ")"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"app": {
|
||
|
|
"type": "REPEAT1",
|
||
|
|
"content": {
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "term"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"axiom": {
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "axiom"
|
||
|
|
},
|
||
|
|
"arrow": {
|
||
|
|
"type": "PREC_LEFT",
|
||
|
|
"value": 1,
|
||
|
|
"content": {
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "app_term"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "->"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": "→"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "expr"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"app_term": {
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "labs"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "pabs"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "app"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"expr": {
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "app_term"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "arrow"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"ascription": {
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": ":"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "expr"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"definition": {
|
||
|
|
"type": "SEQ",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "identifier"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "REPEAT",
|
||
|
|
"content": {
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "param_block"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "ascription"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "BLANK"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": ":="
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "CHOICE",
|
||
|
|
"members": [
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "expr"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "SYMBOL",
|
||
|
|
"name": "axiom"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"type": "STRING",
|
||
|
|
"value": ";"
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"extras": [
|
||
|
|
{
|
||
|
|
"type": "PATTERN",
|
||
|
|
"value": "\\s"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"conflicts": [],
|
||
|
|
"precedences": [],
|
||
|
|
"externals": [],
|
||
|
|
"inline": [],
|
||
|
|
"supertypes": []
|
||
|
|
}
|