forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlevel4-Additions.lark
18 lines (12 loc) · 944 Bytes
/
level4-Additions.lark
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// redefining it entirely since it has many order-depending rules (e.g ask_no_quotes should be after ask and before assign)
command:print | ask | turtle | assign_list | add | remove | sleep | error_ask_no_quotes| assign | error_print_no_quotes | error_invalid
print: _PRINT (_print_argument)? -> print
error_print_no_quotes: _PRINT text -> error_print_nq
ask: var _IS _ASK (_print_argument)?
error_ask_no_quotes: var _IS _ASK text -> error_print_nq
_print_argument: (_SPACE | list_access | quoted_text | var_access)*
// literal strings must be single-quoted in ask and print commands so punctuation should not be treated differently anymore
// anything can be parsed except for a newline, a space and a list separator
textwithoutspaces: /([^\n،, ]+)/ -> text
text: /([^\n،,]+)/ -> text
quoted_text: (/'((?:[^\\']|\\.)*)'/ | /"((?:[^\\"]|\\.)*)"/) -> text //text can be between single or double quotes, but quotes may be escaped with \