forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel6-Additions.lark
33 lines (21 loc) · 2.39 KB
/
level6-Additions.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
_print_ask_argument.1: (_SPACE | quoted_text | list_access | expression | print_expression)*
?print_expression: var_access_print | error_unsupported_number | INT
// redefining it entirely since it has many order-depending rules
command: clear | error_non_decimal | print | turtle | play | add | remove | error_add_missing_to | error_remove_missing_from | error_add_missing_list | error_remove_missing_list | sleep | error_print_no_quotes | error_print_one_quote_only | if_pressed_else | error_if_pressed_missing_else | if_pressed_without_else | ifelse | ifs | error_else_no_if | ask | error_ask_no_quotes | assign | assign_list | error_invalid_space | error_text_no_print | empty_line
_if_less_command: print | turtle | play | add | remove | sleep | error_print_no_quotes | error_print_one_quote_only | ask | error_ask_no_quotes | assign | assign_list
ask: var (_IS | _EQUALS) _ASK _SPACE? (_print_ask_argument)?
error_ask_no_quotes: var (_IS | _EQUALS) _ASK not_letter_or_numeral text -> error_print_nq
play: _PLAY (list_access | expression | textwithoutspaces)
equality_check: (INT | textwithoutspaces) (_IS | _EQUALS) (INT | quoted_text | textwithoutspaces)
condition: >> equality_check
assign_list: var (_IS | _EQUALS) (INT | textwithinnerspaces) (_COMMA (INT | textwithinnerspaces))+ _SPACE?
assign: var (_IS | _EQUALS) (INT | list_access | expression | textwithoutspaces | textwithinnerspaces) _SPACE?
add: _ADD_LIST (INT | text_add_remove_list) _TO_LIST _SPACE var_access
remove: _REMOVE (INT | text_add_remove_list) _FROM _SPACE var_access
sleep: _SLEEP (INT | list_access | var_access | expression)?
turtle: _FORWARD ((NUMBER | list_access | textwithoutspaces | expression))? -> forward | _TURN ((NUMBER | list_access | textwithoutspaces | expression))? -> turn | _COLOR (turtle_color)? -> color
?expression: simple_expression | expression _MULTIPLY atom -> multiplication | expression _DIVIDE atom -> division | expression _PLUS atom -> addition | expression _MINUS atom -> subtraction
?simple_expression: atom _MULTIPLY atom -> multiplication | atom _DIVIDE atom -> division | atom _PLUS atom -> addition | atom _MINUS atom -> subtraction
?atom: INT | var_access | error_unsupported_number | textwithoutspaces
error_unsupported_number: /([-+]?(\d+[\.،,、,]\d+))/ -> error_unsupported_number
?turtle_color: black | blue | brown | gray | green | orange | pink | purple | red | white | yellow | list_access | textwithoutspaces