|
| 1 | +# Leviator BNF |
| 2 | + |
| 3 | +```bnf |
| 4 | +<syntax> ::= <expression>* |
| 5 | +
|
| 6 | +<expression> ::= <alias> | <function> | <comment> |
| 7 | +
|
| 8 | +<alias> ::= "alias " <identifierAlias> " " <replacement> ";\n" |
| 9 | +<identifierAlias> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | |
| 10 | + "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | |
| 11 | + "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" | "a" | |
| 12 | + "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | |
| 13 | + "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | |
| 14 | + "t" | "u" | "v" | "w" | "x" | "y" | "z" | "0" | "1" | |
| 15 | + "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "_" | |
| 16 | + "." | "-" | ":" | "!" | "@" | "#" | "$" | "%" | "^" | |
| 17 | + "&" | "*" | "(" | ")" | "[" | "]" | "{" | "}" | "|" | |
| 18 | + "\\" | "+" | "=" | ";" | "<" | ">" | "?" | "/" | "`" | |
| 19 | + "~" |
| 20 | +<replacement> ::= <char2> |
| 21 | +
|
| 22 | +<comment> ::= "//" <char1>* "\n" |
| 23 | +
|
| 24 | +<function> ::= "fn " <identifier> "(" <parameterList>* ") -> " <type> "\n{\n" <instruction>* "}\n" |
| 25 | +<identifier> ::= <lowerLetter> <char2> |
| 26 | +<parameterList> ::= <parameter> "," |
| 27 | +<parameter> ::= <identifier> ": " <type> |
| 28 | +<type> ::= <upperLetter> <char2> |
| 29 | +<instruction> ::= <instructionIns> ";\n" |
| 30 | +<instructionIns> ::= <declaration> | <assignment> | <functionCall> | <return> | <condition> |
| 31 | +<declaration> ::= "@" <type> " " <identifier> " = " <value> |
| 32 | +<assignment> ::= <identifier> " = " <value> |
| 33 | +<functionCall> ::= <identifier> "(" <varParamList>* ")" |
| 34 | +<varParamList> ::= <value> "," |
| 35 | +<return> ::= "<- " <value> |
| 36 | +<value> ::= <functionCall> | <identifier> | <literal> |
| 37 | +<literal> ::= <digit> | <character> | <bool> | <stringview> |
| 38 | +<condition> ::= <conditionIf> | <conditionIfElse> |
| 39 | +<conditionIfElse> ::= <conditionIf> <conditionElse> |
| 40 | +<conditionIf> ::= "if (" <value> ")\n{\n" <instruction>* "}\n" |
| 41 | +<conditionElse> ::= "else\n{\n" <instruction>* "}\n" |
| 42 | +
|
| 43 | +<character> ::= "'" <char1> "'" |
| 44 | +<bool> ::= "True" | "False" |
| 45 | +<stringview> ::= "\"" <char1>* "\"" |
| 46 | +
|
| 47 | +<char> ::= <lowerLetter> | <upperLetter> | <digit> |
| 48 | +<char1> ::= <char> | "" | " " | <specialAll> |
| 49 | +<char2> ::= <lowerLetter> | <upperLetter> | <digit> | <special> |
| 50 | +<lowerLetter> ::= "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | |
| 51 | + "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | |
| 52 | + "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" |
| 53 | +<upperLetter> ::= "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" | "I" | |
| 54 | + "J" | "K" | "L" | "M" | "N" | "O" | "P" | "Q" | "R" | |
| 55 | + "S" | "T" | "U" | "V" | "W" | "X" | "Y" | "Z" |
| 56 | +<digit> ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" |
| 57 | +<special> ::= "_" |
| 58 | +<specialAll> ::= <special> | "!" | "@" | "#" | "$" | "%" | "^" | "&" | |
| 59 | + "*" | "(" | ")" | "[" | "]" | "{" | "}" | "|" | "\\" | |
| 60 | + "+" | "=" | ";" | "<" | ">" | "?" | "/" | "`" | "~" |
| 61 | +``` |
0 commit comments