-
Notifications
You must be signed in to change notification settings - Fork 0
/
grammar.txt
51 lines (35 loc) · 1.2 KB
/
grammar.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
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
program -> function
function -> subroutine identifier (arguments) code_block
arguments
block -> if_block
block -> for_block
block -> while_block
block -> code_block
do_while_block -> do code_block while (expression)
while_block -> while (expression) code_block
for_block -> for (expression) code_block
if_block -> if (expression) code_block
if_block -> if (expression) code_block else code_block
code_block -> {statements}
statements -> statement; statements
statements -> statement;
statements -> statement
statement -> assignment_statement
statement -> print_statement
statement -> expression
print_statement -> log(expression)
assignment_statement -> identifier = expression
assignment_statement -> put expression in identifier
expression -> -term
expression -> !term
expression -> expression == term
expression -> expression || term
expression -> expression && term
expression -> expression + term
expression -> expression - term
expression -> term
term -> term * factor
term -> term / factor
term -> factor
factor -> literal
factor -> (expression)