tree-sitter-lexd
Version:
tree-sitter parser of Apertium lexd files.
1,612 lines (1,610 loc) • 35.5 kB
JSON
{
"name": "lexd",
"rules": {
"source_file": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_real_nl"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "block_comment"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern_block"
},
{
"type": "SYMBOL",
"name": "lexicon_block"
},
{
"type": "SYMBOL",
"name": "alias_command"
}
]
}
}
]
},
"pattern_block": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern_start"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "named_pattern_start"
},
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
}
]
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_end_com"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_nl"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "pattern_line"
}
}
]
},
"pattern_start": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 1,
"content": {
"type": "STRING",
"value": "PATTERNS"
}
}
},
"named_pattern_start": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 1,
"content": {
"type": "STRING",
"value": "PATTERN"
}
}
},
"lexicon_start": {
"type": "TOKEN",
"content": {
"type": "PREC",
"value": 1,
"content": {
"type": "STRING",
"value": "LEXICON"
}
}
},
"alias": {
"type": "STRING",
"value": "ALIAS"
},
"left_sieve": {
"type": "STRING",
"value": "<"
},
"right_sieve": {
"type": "STRING",
"value": ">"
},
"pattern_or": {
"type": "STRING",
"value": "|"
},
"colon": {
"type": "STRING",
"value": ":"
},
"question_op": {
"type": "STRING",
"value": "?"
},
"star_op": {
"type": "STRING",
"value": "*"
},
"plus_op": {
"type": "STRING",
"value": "+"
},
"pattern_line": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern_token"
},
{
"type": "SYMBOL",
"name": "pattern_option"
},
{
"type": "SYMBOL",
"name": "left_sieve"
},
{
"type": "SYMBOL",
"name": "right_sieve"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "_nl"
}
]
},
"anonymous_pattern": {
"type": "PREC_DYNAMIC",
"value": 20,
"content": {
"type": "PREC",
"value": 20,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern_token"
},
{
"type": "SYMBOL",
"name": "pattern_option"
},
{
"type": "SYMBOL",
"name": "left_sieve"
},
{
"type": "SYMBOL",
"name": "right_sieve"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": ")"
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "STRING",
"value": ")"
}
]
}
]
}
]
}
}
},
"pattern_option": {
"type": "PREC_DYNAMIC",
"value": 30,
"content": {
"type": "PREC_RIGHT",
"value": 30,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "pattern_token"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "pattern_or"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern_token"
},
{
"type": "ALIAS",
"content": {
"type": "SYMBOL",
"name": "pattern_option"
},
"named": false,
"value": "flattened_operator"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
}
]
}
}
},
"pattern_operator": {
"type": "PREC_DYNAMIC",
"value": 3,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "star_op"
},
{
"type": "SYMBOL",
"name": "plus_op"
},
{
"type": "SYMBOL",
"name": "question_op"
}
]
}
},
"lexicon_reference": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "PREC_DYNAMIC",
"value": 2,
"content": {
"type": "FIELD",
"name": "disjoint",
"content": {
"type": "SYMBOL",
"name": "question_op"
}
}
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "column",
"content": {
"type": "SYMBOL",
"name": "number"
}
}
]
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "filter",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "tag_filter"
},
{
"type": "BLANK"
}
]
}
}
]
},
"pattern_token": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "whole",
"content": {
"type": "SYMBOL",
"name": "lexicon_reference"
}
},
{
"type": "PREC",
"value": 2,
"content": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL",
"name": "lexicon_reference"
}
},
{
"type": "SYMBOL",
"name": "colon"
}
]
}
},
{
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "colon"
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "SYMBOL",
"name": "lexicon_reference"
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "SYMBOL",
"name": "lexicon_reference"
}
},
{
"type": "SYMBOL",
"name": "colon"
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "SYMBOL",
"name": "lexicon_reference"
}
}
]
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "whole",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "anonymous_lexicon"
},
{
"type": "SYMBOL",
"name": "anonymous_pattern"
}
]
}
},
{
"type": "FIELD",
"name": "filter",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "tag_filter"
},
{
"type": "BLANK"
}
]
}
}
]
}
]
},
{
"type": "FIELD",
"name": "operator",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern_operator"
},
{
"type": "BLANK"
}
]
}
}
]
},
"neg_tag": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "-"
},
{
"type": "FIELD",
"name": "tag",
"content": {
"type": "SYMBOL",
"name": "tag"
}
}
]
},
"_tag_or_neg": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "tag"
},
{
"type": "SYMBOL",
"name": "neg_tag"
}
]
},
"_tag_list": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_tag_or_neg"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "REPEAT",
"content": {
"type": "PREC_LEFT",
"value": 2,
"content": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": ","
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_tag_or_neg"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
}
]
}
}
}
]
},
"tag_setting": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_tag_list"
},
{
"type": "STRING",
"value": "]"
}
]
},
"tag_distribution_operator": {
"type": "CHOICE",
"members": [
{
"type": "STRING",
"value": "^"
},
{
"type": "STRING",
"value": "|"
}
]
},
"tag_distribution": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "op",
"content": {
"type": "SYMBOL",
"name": "tag_distribution_operator"
}
},
{
"type": "STRING",
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_tag_list"
},
{
"type": "STRING",
"value": "]"
}
]
},
"_tag_filter_segment": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "tag_distribution"
},
{
"type": "SYMBOL",
"name": "_tag_or_neg"
}
]
},
"tag_filter": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_tag_filter_segment"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": ","
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_tag_filter_segment"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "]"
}
]
},
"anonymous_lexicon": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "lexicon_segment"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
"value": "]"
}
]
},
"lexicon_block": {
"type": "PREC",
"value": 2,
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "lexicon_start"
},
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "FIELD",
"name": "name",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "FIELD",
"name": "columns",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "number"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "FIELD",
"name": "defaults",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "tag_setting"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_end_com"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_nl"
},
{
"type": "REPEAT1",
"content": {
"type": "SYMBOL",
"name": "lexicon_line"
}
}
]
}
},
"lexicon_line": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "lexicon_segment"
},
{
"type": "REPEAT",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "SYMBOL",
"name": "lexicon_segment"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_end_com"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_nl"
}
]
},
"regex_char_class": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "["
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "lexicon_string"
},
{
"type": "SYMBOL",
"name": "escaped_char"
}
]
}
},
{
"type": "STRING",
"value": "]"
}
]
},
"regex_string": {
"type": "PATTERN",
"value": "[^\\s\\n\\\\#:\\[\\]\\/()?*+]+"
},
"_plain_regex_string": {
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "regex_string"
},
{
"type": "SYMBOL",
"name": "escaped_char"
},
{
"type": "SYMBOL",
"name": "regex_char_class"
}
]
}
},
"regex_line": {
"type": "PREC_RIGHT",
"value": 0,
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_plain_regex_string"
},
{
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_plain_regex_string"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "colon"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_plain_regex_string"
},
{
"type": "BLANK"
}
]
}
]
}
]
}
},
"regex_group": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "("
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "regex_group"
},
{
"type": "SYMBOL",
"name": "regex_line"
},
{
"type": "SYMBOL",
"name": "pattern_or"
}
]
}
},
{
"type": "STRING",
"value": ")"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "pattern_operator"
},
{
"type": "BLANK"
}
]
}
]
},
"regex": {
"type": "SEQ",
"members": [
{
"type": "STRING",
"value": "/"
},
{
"type": "REPEAT",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "regex_line"
},
{
"type": "SYMBOL",
"name": "regex_group"
},
{
"type": "SYMBOL",
"name": "pattern_or"
}
]
}
},
{
"type": "STRING",
"value": "/"
}
]
},
"_lexicon_side_left": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "lexicon_string"
},
{
"type": "SYMBOL",
"name": "escaped_char"
},
{
"type": "SYMBOL",
"name": "tag_symbol"
},
{
"type": "SYMBOL",
"name": "archiphoneme_symbol"
},
{
"type": "SYMBOL",
"name": "morpheme_boundary"
}
]
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_lexicon_side_right"
},
{
"type": "BLANK"
}
]
}
]
},
"_lexicon_side_right": {
"type": "REPEAT1",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "lexicon_string"
},
{
"type": "SYMBOL",
"name": "escaped_char"
},
{
"type": "ALIAS",
"content": {
"type": "STRING",
"value": "/"
},
"named": true,
"value": "lexicon_string"
},
{
"type": "SYMBOL",
"name": "tag_symbol"
},
{
"type": "SYMBOL",
"name": "archiphoneme_symbol"
},
{
"type": "SYMBOL",
"name": "morpheme_boundary"
}
]
}
},
"lexicon_segment": {
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "tags",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "tag_setting"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "CHOICE",
"members": [
{
"type": "FIELD",
"name": "whole",
"content": {
"type": "PREC",
"value": 2,
"content": {
"type": "SYMBOL",
"name": "regex"
}
}
},
{
"type": "FIELD",
"name": "whole",
"content": {
"type": "SYMBOL",
"name": "_lexicon_side_left"
}
},
{
"type": "SEQ",
"members": [
{
"type": "FIELD",
"name": "left",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_lexicon_side_left"
},
{
"type": "BLANK"
}
]
}
},
{
"type": "SYMBOL",
"name": "colon"
},
{
"type": "FIELD",
"name": "right",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_lexicon_side_right"
},
{
"type": "BLANK"
}
]
}
}
]
}
]
},
{
"type": "FIELD",
"name": "tags",
"content": {
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "tag_setting"
},
{
"type": "BLANK"
}
]
}
}
]
},
"lexicon_string": {
"type": "PATTERN",
"value": "[^\\s\\n\\\\#:\\[\\]\\/<>{]+"
},
"morpheme_boundary": {
"type": "STRING",
"value": ">"
},
"tag_symbol": {
"type": "PATTERN",
"value": "<([^>\\n\\\\]|\\\\.)+>"
},
"archiphoneme_symbol": {
"type": "PATTERN",
"value": "{([^}\\n\\\\]|\\\\.)+}"
},
"escaped_char": {
"type": "PATTERN",
"value": "\\\\."
},
"comment": {
"type": "PATTERN",
"value": "#[^\\n]*"
},
"_end_com": {
"type": "SEQ",
"members": [
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "BLANK"
}
]
},
{
"type": "FIELD",
"name": "comment",
"content": {
"type": "SYMBOL",
"name": "comment"
}
}
]
},
"alias_command": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "alias"
},
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "FIELD",
"name": "src",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "SYMBOL",
"name": "_ws"
},
{
"type": "FIELD",
"name": "trg",
"content": {
"type": "SYMBOL",
"name": "identifier"
}
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "_end_com"
},
{
"type": "BLANK"
}
]
},
{
"type": "SYMBOL",
"name": "_nl"
}
]
},
"identifier": {
"type": "PATTERN",
"value": "[^\\s?|()<>\\[\\]*+:]+"
},
"tag": {
"type": "PATTERN",
"value": "[^\\s?|()<>\\[\\]*+,^-][^\\s?|()<>\\[\\]*+,^]*"
},
"number": {
"type": "PATTERN",
"value": "\\(\\d+\\)"
},
"_real_nl": {
"type": "PATTERN",
"value": "[ \\t]*\\n[ \\t\\n]*"
},
"block_comment": {
"type": "REPEAT1",
"content": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "comment"
},
{
"type": "SYMBOL",
"name": "_real_nl"
}
]
}
},
"_nl": {
"type": "SEQ",
"members": [
{
"type": "SYMBOL",
"name": "_real_nl"
},
{
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "block_comment"
},
{
"type": "BLANK"
}
]
}
]
},
"_ws": {
"type": "PATTERN",
"value": "[ \\t]+"
}
},
"extras": [
{
"type": "PATTERN",
"value": "\\s"
}
],
"conflicts": [
[
"lexicon_reference"
],
[
"pattern_token"
]
],
"precedences": [],
"externals": [],
"inline": [],
"supertypes": []
}