-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpythonicEnglish.lark
120 lines (87 loc) · 2.55 KB
/
pythonicEnglish.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
?start: statement
| command
| create
| next_
?expression: int
| quantity
| array_comprehension
| sum
| difference
| product
| call
| list
| length
| equals
| quote
| comparison
| array_element
| end_array_elements
| word
length: "the length of " expression
comparison: expression " is " comparator " " expression
comparator: "less than" -> lt
| "greater than" -> gt
| "less than or equal to" -> lte
| "greater than or equal to" -> gte
| "equal to" -> eq
call: "call " function_name " with parameters " tuple
| "result of " function_name " with parameters " tuple
| "call " function_name " of " tuple
| "result of " function_name " of " tuple
list: "list of " expression (" and " expression)*
| "list of " expression (" comma " expression)*
| empty_list
equals: expression " equals " expression
quote: "quote " word " unquote"
tuple: expression (" and " expression)*
| expression (" comma " expression)*
?empty_list: "empty list"
?function_name: word
?variable_name: word
sum: expression " plus " expression
product: expression " times " expression
array_element: "element " int " of " variable_name
| "element at " expression " in " variable_name
end_array_elements: "elements " expression " through end of " variable_name
array_comprehension: expression " for " variable_name " in " expression " if " comparison
?quantity: "quantity " sum
| "quantity " difference
| "quantity " product
difference: expression " minus " expression
definition: "define " function_name " with parameters " tuple " and body " statement* " done"
statement: return_
| ifelse
| expression
| definition
| set_var
| statement " then " statement
ifelse: "if " expression " then " statement [(" otherwise if " expression " then " statement)*] [" else " statement]
return_: "return " expression
set_var: "set " variable_name " to " expression
int: NUMBER
?word: WORD
?command: next_word
| previous_word
| back
| teleport_line
| teleport_word
teleport_line: "teleport to line " int
teleport_word: "teleport to " word
?next_word: "next word"
?previous_word: "previous word"
?back: "backspace"
?create: create_for_range
| create_if
| create_for_loop
| create_def
| create_else
create_for_range: "create range"
create_if: "create if"
create_for_loop: "create loop"
create_def: "create function"
create_else: "create else"
next_: expression " next"
| statement " next"
%import common.NUMBER
%import common.ESCAPED_STRING
%import common.WORD