-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlangwej.bnf
More file actions
48 lines (39 loc) · 2.42 KB
/
langwej.bnf
File metadata and controls
48 lines (39 loc) · 2.42 KB
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
keyword ::= "whil" | "if" | "else" | "stonks" | "not_stonks" | "retun" | "intijur" | "flote" | "bulen" | "strin"
| "funkshun" | "array" | "coll" | "null" | "let" | "char"
symbol ::= "{" | "}" | "(" | ")" | "[" | "]" | ";" | "," | "+" | "-" | "*" | "/" | "%" |
">" | "<" | ">=" | "<=" | "==" | "!=" | "=" | "||" | "&&" | "!"
arithmeticOperator ::= "+" | "-" | "*" | "/" | "%"
relationalOperator ::= ">" | "<" | ">=" | "<=" | "==" | "!="
logicalOperator ::= "||" | "&&"
operator ::= arithmeticOperator | relationalOperator | logicalOperator
unaryOperator ::= "-" | "+" | "!"
delimiter ::= "{" | "}" | "(" | ")" | "[" | "]" | ";" | ","
alphabets ::= ( [a-z] | [A-Z] | "_" )+
number ::= [0-9]+
alphanumeral ::= ( alphabets | number )+
constant ::= integerConstant | floatConstant | booleanConstant | stringConstant | charConstant | "null"
integerConstant ::= ("+" | "-")? number
floatConstant ::= ("+" | "-")? number ("." number)? [(("E" | "e") ("+" | "-")? number)?]?
booleanConstant ::= "stonks" | "not_stonks"
stringConstant ::= "\"" (.*) "\""
arrayConstant ::= "[" ( constant ("," constant)* )? "]"
charConstant ::= "'" (.) "'"
dataType ::= "intijur" | "flote" | "bulen" | "strin" | "char" | arrayType
arrayType ::= "array" "<" ("intijur" | "flote" | "bulen" | "strin") ">"
identifier ::= alphabets ( alphabets | number )*
varName ::= identifier
term ::= constant | varName | varName "[" expression "]" | "(" expression ")" | functionCall | unaryOperator term
statement ::= declarationStatement | letStatement | ifStatement | whileStatement | callStatement | returnStatement
declarationStatement ::= dataType varName ("=" expression)? (("," varName)+)? ";"
letStatement ::= ( "let" varName ("[" expression "]")? "=" expression ";" ) | ( "let" varName "=" arrayExpression ";" )
ifStatement ::= "if" "(" expression ")" "{" statement* "}" ("else" "{" statement* "}")?
whileStatement ::= "whil" "(" expression ")" "{" statement* "}"
callStatement ::= "coll" functionCall
returnStatement ::= "retun" expression | arrayExpression ";"
expression ::= term (operator term)*
arrayExpression ::= "[" ( expression ("," expression)* )? "]"
functionDefinition ::= dataType "funkshun" functionName "(" parameterList ")" { statement* returnStatement }
parameterList ::= ( dataType identifier ("," dataType identifier)* )?
functionCall ::= functionName ( ( term ("," term)* )? ) ";"
functionName ::= identifier
program ::= ( functionDefinition | statement )*