forked from hedyorg/hedy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
level3.txt
27 lines (22 loc) · 1.1 KB
/
level3.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
start: program
program: command ("\n" command)*
command: "print " (quoted_text | list_access | var) (" " (quoted_text | list_access | var))* -> print
| "ask " textwithspaces punctuation* -> ask
| "echo " textwithspaces punctuation* -> echo
| text " is " text ((", "|",") text)+ -> assign_list
| text " is " text -> assign //placing it here means print is will print 'is' and print is Felienne will print 'is Felienne'
| text " " textwithspaces -> invalid
var: LETTER+ -> var
list_access : var " at " (index | random) -> list_access
index : DIGIT+
random : "random"
punctuation : PUNCTUATION -> punctuation
textwithspaces: (LETTER | DIGIT | WS_INLINE)+ -> text
quoted_text: QUOTE (LETTER | DIGIT | PUNCTUATION | WS_INLINE)+ QUOTE -> text
QUOTE : "'"
text: (LETTER | DIGIT)+ -> text
PUNCTUATION: "!" | "?" | "." //uppercase places tokens in tree
%import common.LETTER // imports from terminal library
%import common.DIGIT // imports from terminal library
%import common.WS_INLINE // imports from terminal library
%import common.NEWLINE // imports from terminal library