-
-
Notifications
You must be signed in to change notification settings - Fork 433
/
Copy pathlark.lark
50 lines (35 loc) · 1.02 KB
/
lark.lark
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
start: (_item | _NL)*
_item: rule
| token
| statement
rule: RULE priority? ":" expansions _NL
token: TOKEN priority? ":" expansions _NL
priority: "." NUMBER
statement: "%ignore" expansions _NL -> ignore
| "%import" import_args ["->" TOKEN] _NL -> import
| "%declare" name+ -> declare
import_args: name ("." name)*
?expansions: alias (_VBAR alias)*
?alias: expansion ["->" RULE]
?expansion: expr*
?expr: atom [OP | "~" NUMBER [".." NUMBER]]
?atom: "(" expansions ")"
| "[" expansions "]" -> maybe
| STRING ".." STRING -> literal_range
| name
| (REGEXP | STRING) -> literal
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.INT -> NUMBER
%import common.WS_INLINE
COMMENT: "//" /[^\n]/*
%ignore WS_INLINE
%ignore COMMENT