Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

57 Commits

Repository files navigation

MicroJava++ 🐧

Implementation of the programming language compiler. Based on the Truffle framework. MicroJava as the base grammar for MicroJava++

forthebadgeforthebadgeforthebadge

forthebadgeforthebadge

Table of contents

Language description

Grammar

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 = "​*​" ​| ​"​/​" ​| ​"​%​". 

Extensions 💰

MicroJava++ supports additional features, not sated in the grammar:

  • 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;

Not implemented yet ⏩

  • 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;

Team 💡

Roman MilishchuckHermann Yavorskyi
"I am starting to like Java... LoL, I fooled you."💥💀

About

MicroJava++

Topics

Resources

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages