-
Notifications
You must be signed in to change notification settings - Fork 0
/
Language.bnf
122 lines (92 loc) · 3.84 KB
/
Language.bnf
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
<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
<digits> ::= <digit>
| <digits> <digit>
<character> ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z"
<characters> ::= <character>
| <characters> <character>
<digit-or-character> ::= <digit>
| <character>
<digits-and-characters> ::= <digit-or-character> | <digits-and-characters> <digit-or-character>
<symbol> ::= "|" | " " | "!" | "#" | "$" | "%" | "&" | "(" | ")" | "*" | "+" | "," | "-" | "." | "/" | ":" | ";" | ">" | "=" | "<" | "?" | "@" | "[" | "\\" | "]" | "^" | "_" | "'" | "\'" | "{" | "}" | "~" | "\n" | "\r" | "\t" | "\""
<symbols> ::= <symbol>
| <symbols> <symbol>
<text> ::= <digit>
| <character>
| <symbol>
<all-text-symbols> ::= <text> | <all-text-symbols> <text>
<constant> ::= <digits>
| <digits> "." <digits>
| <digits> "."
| "." <digits>
<string> ::= "'" <all-text-symbols> "'"
| "\"" <all-text-symbols> "\""
<factor> ::= "(" <expression> ")""
| <constant>
| <identifier>
| <function-call>
| <string>
<unary> ::= <factor>
| <unary-symbols> <factor>
<term> ::= <term> "*" <unary>
| <term> "/" <unary>
| <unary>
<math> ::= <math> "+" <term>
| <math> "-" <term>
| <term>
<relational> ::= <math> <relational-symbol> <math>
| <math>
<operator-and> ::= <relational>
| <operator-and> "&&" <relational>
<expression> ::= <operator-and>
| <expression> "||" <operator-and>
<unary-symbol> ::= "-"
| "!"
<unary-symbols> ::= <unary-symbol>
| <unary-symbols> <unary-symbol>
<relational-symbol> ::= "=="
| ">="
| "<="
| "!="
| ">"
| "<"
<type> ::= "int"
| "string"
| "float"
<identifier> ::= <digits-and-characters>
<declaration-statement> ::= | <type> <identifier> ";"
| <type> <identifier> "=" <expression> ";"
<arguments> ::= <expression>
| <arguments> "," <expression>
<function-call> ::= <identifier> "(" ")"
| <identifier> "(" <arguments> ")"
<call-statement> ::= <function-call> ";"
<assignment-statement> ::= <identifier> "=" <expression> ";"
<jump-statement> ::= "nutraukti" ";"
| "testi" ";"
| "grazinti" ";"
| "grazinti" <expression> ";"
<statement-region> ::= ":" "(" <statements> ")"
| ":" "(" ")"
<pakolei-statement> ::= "pakolei" "(" <expression> ")" <statement-region>
<kitaip-statement> ::= "kitaip" <statement-region>
<kitaip-jei-statement> ::= "kitaip-jei" "(" <expression> ")" <statement-region>
| "kitaip-jei" "(" <expression> ")" <statement-region> <kitaip-jei-statement>
| "kitaip-jei" "(" <expression> ")" <statement-region> <kitaip-statement>
<jei-statement> ::= "jei" "(" <expression> ")" <statement-region>
| "jei" "(" <expression> ")" <statement-region> <kitaip-jei-statement>
| "jei" "(" <expression> ")" <statement-region> <kitaip-statement>
<statement> ::= <jei-statement>
| <pakolei-statement>
| <jump-statement>
| <call-statement>
| <assignment-statement>
| <declaration-statement>
<statements> ::= <statement>
| <statements> <statement>
<parameters> ::= <type> <identifier>
| <parameters> "," <type> <identifier>
<function-statement> ::= <type> <identifier> "(" <parameters> ")" <statement-region>
| <type> <identifier> "(" ")" <statement-region>
<functions> ::= <function-statement>
| <functions> <function-statement>
<start> ::= <functions> EOF