-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_grammar.txt
73 lines (72 loc) · 2.37 KB
/
test_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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
TERMINALS
OPENPARENTHESIS = (
CLOSEPARENTHESIS = )
OPENBRACE = {
CLOSEBRACE = }
OPENANGLEBRACKET = <
CLOSEANGLEBRACKET = >
VOID = void
INTTYPE = int
FLOATTYPE = float
COMMA = ,
EQUALS = =
SEMICOLON = ;
IF = if
ELSE = else
WHILE = while
RETURN = return
TRUE = true
FALSE = false
INT = 45
PLUS = +
DASH = -
ASTERISK = *
FORWARDSLASH = /
AMPERSAND = &
PIPE = |
IDENTIFIER = name
GRAMMAR_RULES
Start = FunctionList
FunctionList = Function
FunctionList = FunctionList Function
Function = FunctionReturnType IDENTIFIER OPENPARENTHESIS CLOSEPARENTHESIS OPENBRACE StatementList CLOSEBRACE
Function = FunctionReturnType IDENTIFIER OPENPARENTHESIS ArgumentList CLOSEPARENTHESIS OPENBRACE StatementList CLOSEBRACE
Function = FunctionReturnType IDENTIFIER OPENPARENTHESIS CLOSEPARENTHESIS OPENBRACE CLOSEBRACE
Function = FunctionReturnType IDENTIFIER OPENPARENTHESIS ArgumentList CLOSEPARENTHESIS OPENBRACE CLOSEBRACE
FunctionReturnType = VOID
FunctionReturnType = VariableType
VariableType = INTTYPE
VariableType = FLOATTYPE
ArgumentList = Argument
ArgumentList = ArgumentList COMMA Argument
Argument = VariableType IDENTIFIER
StatementList = Statement
StatementList = StatementList Statement
Statement = VariableAssignment
VariableAssignment = VariableType IDENTIFIER EQUALS Expression SEMICOLON
VariableAssignment = IDENTIFIER EQUALS Expression SEMICOLON
Statement = Conditional
Conditional = IfBlock
Conditional = IfBlock ElseBlock
IfBlock = IF OPENPARENTHESIS Expression CLOSEPARENTHESIS OPENBRACE StatementList CLOSEBRACE
ElseBlock = ELSE OPENBRACE StatementList CLOSEBRACE
Statement = WhileBlock
WhileBlock = WHILE OPENPARENTHESIS Expression CLOSEPARENTHESIS OPENBRACE StatementList CLOSEBRACE
Statement = Return
Return = RETURN SEMICOLON
Return = RETURN Expression SEMICOLON
Expression = TRUE
Expression = FALSE
Expression = INT
Expression = Expression PLUS Expression
Expression = Expression DASH Expression
Expression = Expression ASTERISK Expression
Expression = Expression FORWARDSLASH Expression
Expression = Expression AMPERSAND AMPERSAND Expression
Expression = Expression PIPE PIPE Expression
Expression = Expression OPENANGLEBRACKET Expression
Expression = Expression CLOSEANGLEBRACKET Expression
Expression = Expression OPENANGLEBRACKET EQUALS Expression
Expression = Expression CLOSEANGLEBRACKET EQUALS Expression
Expression = Expression EQUALS EQUALS Expression
Expression = OPENPARENTHESIS Expression CLOSEPARENTHESIS