-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Lark grammar files (#5049)
- Loading branch information
Showing
6 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
?start: line | ||
|
||
?line: empty_line | ||
| note_line | ||
| text_line | ||
| dollar_line | ||
| at_line | ||
| control_line | ||
|
||
empty_line: /\s+/? | ||
|
||
!control_line.-2: ("=:" | "&" | "#") /.+/? | ||
|
||
%import .ebl_atf_text_line (text_line, any_word, note_line) | ||
%import .ebl_atf_dollar_line (dollar_line) | ||
%import .ebl_atf_at_line (at_line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
%import common.DIGIT | ||
%import common.INT | ||
%import common.LCASE_LETTER | ||
|
||
seal : "seal " INT | ||
|
||
free_text.-2 : /./+ " "* | ||
|
||
?object: OBJECT | generic_object | fragment | ||
OBJECT: "tablet" | "envelope" | "prism" | "bulla" | ||
fragment: "fragment " free_text | ||
generic_object : "object " free_text | ||
|
||
?surface: SURFACE | generic_surface | face | edge | ||
SURFACE: "obverse" | "reverse" | "left" | "right" | "top" | "bottom" | ||
face: "face " LCASE_LETTER | ||
edge: "edge" (" " LCASE_LETTER)? | ||
generic_surface : "surface " free_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
start: (_item? _NL)* _item? | ||
|
||
_item: rule | ||
| token | ||
| statement | ||
|
||
rule: RULE rule_params priority? ":" expansions | ||
token: TOKEN token_params priority? ":" expansions | ||
|
||
rule_params: ["{" RULE ("," RULE)* "}"] | ||
token_params: ["{" TOKEN ("," TOKEN)* "}"] | ||
|
||
priority: "." NUMBER | ||
|
||
statement: "%ignore" expansions -> ignore | ||
| "%import" import_path ["->" name] -> import | ||
| "%import" import_path name_list -> multi_import | ||
| "%declare" name+ -> declare | ||
|
||
!import_path: "."? name ("." name)* | ||
name_list: "(" name ("," name)* ")" | ||
|
||
?expansions: alias (_VBAR alias)* | ||
|
||
?alias: expansion ["->" RULE] | ||
|
||
?expansion: expr* | ||
|
||
?expr: atom [OP | "~" NUMBER [".." NUMBER]] | ||
|
||
?atom: "(" expansions ")" | ||
| "[" expansions "]" -> maybe | ||
| value | ||
|
||
?value: STRING ".." STRING -> literal_range | ||
| name | ||
| (REGEXP | STRING) -> literal | ||
| name "{" value ("," value)* "}" -> template_usage | ||
|
||
name: RULE | ||
| TOKEN | ||
|
||
_VBAR: _NL? "|" | ||
OP: /[+*]|[?](?![a-z])/ | ||
RULE: /!?[_?]?[a-z][_a-z0-9]*/ | ||
TOKEN: /_?[A-Z][_A-Z0-9]*/ | ||
STRING: _STRING "i"? | ||
REGEXP: /\/(?!\/)(\\\/|\\\\|[^\/\n])*?\/[imslux]*/ | ||
_NL: /(\r?\n)+\s*/ | ||
|
||
%import common.ESCAPED_STRING -> _STRING | ||
%import common.SIGNED_INT -> NUMBER | ||
%import common.WS_INLINE | ||
|
||
COMMENT: /\s*/ "//" /[^\n]/* | ||
|
||
%ignore WS_INLINE | ||
%ignore COMMENT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters