Implementation of the programming language compiler. Based on the Truffle framework. MicroJava as the base grammar for MicroJava++
Also known as MicroJava - Grammatik 👽
Program = "program" ident { ConstDecl | VarDecl | ClassDecl } "{" {MethodDecl} "}".
ConstDecl = "final" Type ident "=" ( number | charConst ) ";".
VarDecl = Type ident { "," ident } ";".
ClassDecl = "class" ident "{" { VarDecl } "}".
MethodDecl = ( T ype | "void" ) ident "(" [ FormPars ] ")" { V arDecl } Block.
FormPars = Type ident { "," Type ident }. Type = ident [ "[" "]" ].
Block = "{" { Statement } "}".
Statement = Designator ( Assignop Expr | ActPars | "++" | "--" ) ";"
| "if" "(" Condition ")" Statement [ "else" Statement ]
| "while" "(" Condition ")" Statement
| "break" ";" | "continue" ";"
| "return" [ Expr ] ";"
| "read" "(" Designator ")" ";"
| "print" "(" Expr [ "," number ] ")" ";"
| Block
| ";".
Assignop = "=" | "+=" | "-=" | "*=" | "/=" | "%=".
ActPars = "(" [ Expr { "," Expr } ] ")".
Condition = CondTerm { "||" CondTerm }.
CondTerm = CondFact { "&&" CondFact }.
CondFact = Expr Relop Expr. Relop = "==" | "!=" | ">" | ">=" | "<" | "<=".
Expr = [ "–" ] Term { Addop Term }. Term = Factor { Mulop Factor }.
Factor = Designator [ ActPars ]
| number
| charConst
| "new" ident [ "[" Expr "]" ]
| "(" Expr ")".
Designator = ident { "." ident | "[" Expr "]" }.
Addop = "+" | "–".
Mulop = "*" | "/" | "%".
- Scoping (Functions` and blocks` scopes, we are very proud of this! 🙌);
- Declaring variables inside of funtions/blocks;
- Declaring constant variables inside the functions/blocks;
- Constant variables can be initialized with expression, not only literal (inside of the block, global variables suport only literal initilization);
- Supported types: Integer, Boolean, Character, Double;
- Arrays - Nodes for arrays were implemented, but to work corectly with scoping system, there is still work to be done;
- Classes - TBD;
- For/Foreach - After adding arrays, to make work with them more convinient;
- auto keyword - For type deduction;
- Ternary operator - The functional way, is the righ way;
Roman Milishchuck | Hermann Yavorskyi |
---|---|
"I am starting to like Java... LoL, I fooled you." |
💥💀 |