-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgramatika.txt
133 lines (111 loc) · 4.41 KB
/
gramatika.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# source
source -> definitions .
# definitions
definitions -> definition definitions2 .
definitions2 -> ';' definitions .
definitions2 -> .
# definition
definition -> type_definition .
definition -> function_definition .
definition -> variable_definition .
# type_definition
type_definition -> typ identifier ':' type .
# type
type -> identifier .
type -> logical .
type -> integer .
type -> string .
type -> arr '[' int_const ']' type .
# function_definition
function_definition -> fun identifier '(' parameters ')' ':' type '=' expression .
# parameters
parameters -> parameter parameters2 .
parameters2 -> ',' parameters .
parameters2 -> .
# parameter
parameter -> identifier ':' type .
# expression
expression -> logical_ior_expression expression2 .
expression2 -> '{' WHERE definitions '}' .
expression2 -> .
# logical_ior_expression
logical_ior_expression -> logical_and_expression logical_ior_expression2 .
logical_ior_expression2 -> '|' logical_ior_expression .
logical_ior_expression2 -> .
### logical_ior_expression (DRUGAČE / Lažje za levo asociativnost)
logical_ior_expression -> logical_and_expression logical_ior_expression2 .
logical_ior_expression2 -> '|' logical_and_expression logical_ior_expression2 .
logical_ior_expression2 -> .
###
# logical_and_expression
logical_and_expression -> compare_expression logical_and_expression2 .
logical_and_expression2 -> '&' logical_and_expression .
logical_and_expression2 -> .
### logical_and_expression
logical_and_expression -> compare_expression logical_and_expression2 .
logical_and_expression2 -> '&' compare_expression logical_and_expression2 .
logical_and_expression2 -> .
###
# compare_expression
compare_expression -> additive_expression compare_expression2 .
compare_expression2 -> '==' additive_expression .
compare_expression2 -> '!=' additive_expression .
compare_expression2 -> '<=' additive_expression .
compare_expression2 -> '>=' additive_expression .
compare_expression2 -> '<' additive_expression .
compare_expression2 -> '>' additive_expression .
compare_expression2 -> .
# additive_expression
additive_expression -> multiplicative_expression additive_expression2 .
additive_expression2 -> '+' additive_expression .
additive_expression2 -> '-' additive_expression .
additive_expression2 -> .
### additive_expression ALTERNATIVA
additive_expression -> multiplicative_expression additive_expression2 .
additive_expression2 -> '+' multiplicative_expression additive_expression2 .
additive_expression2 -> '-' multiplicative_expression additive_expression2 .
additive_expression2 -> .
###
# multiplicative_expression
multiplicative_expression -> prefix_expression multiplicative_expression2 .
multiplicative_expression2 -> '*' multiplicative_expression .
multiplicative_expression2 -> '/' multiplicative_expression .
multiplicative_expression2 -> '%' multiplicative_expression .
multiplicative_expression2 -> .
### multiplicative_expression ALTERNATIVA
multiplicative_expression -> prefix_expression multiplicative_expression2 .
multiplicative_expression2 -> '*' prefix_expression multiplicative_expression2 .
multiplicative_expression2 -> '/' prefix_expression multiplicative_expression2 .
multiplicative_expression2 -> '%' prefix_expression multiplicative_expression2 .
multiplicative_expression2 -> .
###
# prefix_expression
prefix_expression -> "+" prefix_expression .
prefix_expression -> "-" prefix_expression .
prefix_expression -> "!" prefix_expression .
prefix_expression -> postfix_expression .
# postfix_expression
postfix_expression -> atom_expression postfix_expression2 .
postfix_expression2 -> '[' expression ']' postfix_expression2 .
postfix_expression2 -> .
# atom_expression
atom_expression -> log_constant .
atom_expression -> int_constant .
atom_expression -> str_constant .
atom_expression -> identifier atom_expression2 .
atom_expression2 -> '(' expressions ')' .
atom_expression2 -> .
atom_expression -> '{' atom_expression3 '}' .
atom_expression3 -> expression '=' expression .
atom_expression3 -> if expression then expression atom_expression4 .
atom_expression4 -> .
atom_expression4 -> else expression .
atom_expression3 -> while expression ':' expression .
atom_expression3 -> for identifier '=' expression ',' expression ',' expression ':' expression .
atom_expression -> '(' expressions ')' .
# expressions
expressions -> expression expressions2 .
expressions2 -> .
expressions2 -> ',' expression expressions2 .
# variable_definition
variable_definition -> var identifier ':' type .