tree-sitter-twolc
Version:
tree-sitter grammar of hfst-twolc
981 lines (979 loc) • 20.9 kB
JSON
{
"name": "twolc",
"rules": {
"source_file": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "alphabet"
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "sets"
},
{
"type": "SYMBOL",
"name": "definitions"
},
{
"type": "SYMBOL",
"name": "diacritics"
},
{
"type": "SYMBOL",
"name": "rule_variables"
}
]
}
},
{
"type": "SYMBOL",
"name": "rules"
}
]
},
"semicolon": {
"type": "STRING",
"value": ";"
},
"alphabet_header": {
"type": "STRING",
"value": "Alphabet"
},
"alphabet": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "alphabet_header"
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "symbol"
},
{
"type": "SYMBOL",
"name": "symbol_pair"
}
]
}
},
{
"type": "SYMBOL",
"name": "semicolon"
}
]
},
"diacritics_header": {
"type": "STRING",
"value": "Diacritics"
},
"diacritics": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "diacritics_header"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "symbol"
}
},
{
"type": "SYMBOL",
"name": "semicolon"
}
]
},
"rule_variables_header": {
"type": "STRING",
"value": "Rule-variables"
},
"rule_variables": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "rule_variables_header"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "symbol"
}
},
{
"type": "SYMBOL",
"name": "semicolon"
}
]
},
"sets_header": {
"type": "STRING",
"value": "Sets"
},
"sets": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "sets_header"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "set"
}
}
]
},
"eq": {
"type": "STRING",
"value": "="
},
"set": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "symbol"
}
},
{
"type": "SYMBOL",
"name": "eq"
},
{
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "symbol"
},
{
"type": "SYMBOL",
"name": "symbol_pair"
}
]
}
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "semicolon"
}
}
]
},
"definitions_header": {
"type": "STRING",
"value": "Definitions"
},
"definitions": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "definitions_header"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "definition"
}
}
]
},
"definition": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "symbol"
}
},
{
"type": "SYMBOL",
"name": "eq"
},
{
"type": "FIELD",
"name": "pattern",
"content": {
"type": "SYMBOL",
"name": "pattern"
}
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "semicolon"
}
}
]
},
"rules_header": {
"type": "STRING",
"value": "Rules"
},
"rules": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "rules_header"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "rule"
}
}
]
},
"arrow": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "=>"
},
{
"type": "STRING",
"value": "<="
},
{
"type": "STRING",
"value": "<=>"
},
{
"type": "STRING",
"value": "/<="
}
]
},
"regex_arrow": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "==>"
},
{
"type": "STRING",
"value": "<=="
},
{
"type": "STRING",
"value": "<==>"
},
{
"type": "STRING",
"value": "/<=="
}
]
},
"rule": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "rule_name"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "target",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "symbol"
},
{
"type": "SYMBOL",
"name": "symbol_pair"
}
]
}
},
{
"type": "FIELD",
"name": "arrow",
"content": {
"type": "SYMBOL",
"name": "arrow"
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "target",
"content": {
"type": "SYMBOL",
"name": "regex_target"
}
},
{
"type": "FIELD",
"name": "arrow",
"content": {
"type": "SYMBOL",
"name": "regex_arrow"
}
}
]
}
]
},
{
"type": "FIELD",
"name": "contexts",
"content": {
"type": "SYMBOL",
"name": "positive_contexts"
}
},
{
"type": "FIELD",
"name": "neg_contexts",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "negative_contexts"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "FIELD",
"name": "variables",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "variables"
},
{
"type": "BLANK"
}
]
}
}
]
},
"regex_target": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "<["
},
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "STRING",
"value": "]>"
}
]
},
"positive_contexts": {
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "context"
}
},
"negative_contexts": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "except"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "context"
}
}
]
},
"rule_name": {
"type": "PATTERN",
"value": "\"[^\\\"\\n]+\""
},
"locus": {
"type": "STRING",
"value": "_"
},
"context": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "FIELD",
"name": "locus",
"content": {
"type": "SYMBOL",
"name": "locus"
}
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "semicolon"
}
}
]
},
"except": {
"type": "STRING",
"value": "except"
},
"where": {
"type": "STRING",
"value": "where"
},
"variable_keyword": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "mixed"
},
{
"type": "STRING",
"value": "matched"
}
]
},
"in_keyword": {
"type": "STRING",
"value": "in"
},
"variables": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "where"
},
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "symbol"
}
},
{
"type": "SYMBOL",
"name": "in_keyword"
},
{
"type": "FIELD",
"name": "set",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "symbol"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "loptional"
},
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "roptional"
}
]
}
]
}
}
]
}
},
{
"type": "FIELD",
"name": "type",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "variable_keyword"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "semicolon"
}
]
},
"lpar": {
"type": "STRING",
"value": "["
},
"rpar": {
"type": "STRING",
"value": "]"
},
"loptional": {
"type": "STRING",
"value": "("
},
"roptional": {
"type": "STRING",
"value": ")"
},
"prefix_op": {
"type": "PATTERN",
"value": "[~\\\\$]"
},
"suffix_op": {
"type": "PATTERN",
"value": "([*+^]|\\.[ruli]|\\^\\d+(,\\d+)?)"
},
"ignore_op": {
"type": "STRING",
"value": "/"
},
"bool_op": {
"type": "PATTERN",
"value": "[|&-]"
},
"replace_op": {
"type": "PATTERN",
"value": "->|=>"
},
"compose_op": {
"type": "PATTERN",
"value": "\\.[xo]\\."
},
"word_boundary": {
"type": "STRING",
"value": ".#."
},
"any": {
"type": "STRING",
"value": "?"
},
"pattern": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "symbol"
},
{
"type": "SYMBOL",
"name": "symbol_pair"
},
{
"type": "SYMBOL",
"name": "word_boundary"
},
{
"type": "SYMBOL",
"name": "any"
},
{
"type": "PREC",
"value": 8,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "lpar"
},
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "rpar"
}
]
}
},
{
"type": "PREC",
"value": 8,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "loptional"
},
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "roptional"
}
]
}
},
{
"type": "PREC",
"value": 7,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "prefix_op"
},
{
"type": "SYMBOL",
"name": "pattern"
}
]
}
},
{
"type": "PREC",
"value": 6,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "suffix_op"
}
]
}
},
{
"type": "PREC_LEFT",
"value": 5,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "ignore_op"
},
{
"type": "SYMBOL",
"name": "pattern"
}
]
}
},
{
"type": "PREC_LEFT",
"value": 4,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "pattern"
}
]
}
},
{
"type": "PREC_LEFT",
"value": 3,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "bool_op"
},
{
"type": "SYMBOL",
"name": "pattern"
}
]
}
},
{
"type": "PREC_LEFT",
"value": 2,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "replace_op"
},
{
"type": "SYMBOL",
"name": "pattern"
}
]
}
},
{
"type": "PREC_LEFT",
"value": 1,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "pattern"
},
{
"type": "SYMBOL",
"name": "compose_op"
},
{
"type": "SYMBOL",
"name": "pattern"
}
]
}
}
]
},
"symbol": {
"type": "PATTERN",
"value": "(%.|[^\\s%:\\[\\]~\\\\$*+^/|&-=?()\"_!]|[0-9'\\.,])+"
},
"_imm_sym": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "PATTERN",
"value": "(%.|[^\\s%:\\[\\]~\\\\$*+^/|&-=?()\"_!]|[0-9'\\.,])+"
}
},
"colon": {
"type": "STRING",
"value": ":"
},
"symbol_pair": {
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL",
"name": "symbol"
}
},
{
"type": "ALIAS",
"content": {
"type": "IMMEDIATE_TOKEN",
"content": {
"type": "STRING",
"value": ":"
}
},
"named": true,
"value": "colon"
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_imm_sym"
},
"named": true,
"value": "symbol"
},
{
"type": "BLANK"
}
]
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "colon"
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "CHOICE",
"members": [
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "_imm_sym"
},
"named": true,
"value": "symbol"
},
{
"type": "BLANK"
}
]
}
}
]
}
]
},
"comment": {
"type": "PATTERN",
"value": "![^\\n]*"
}
},
"extras": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "PATTERN",
"value": "[\\s\\n]"
}
],
"conflicts": [],
"precedences": [],
"externals": [],
"inline": [],
"supertypes": []
}