Skip to content

SamadiPour/SimpleCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SimpleCompiler

JavaFX SimpleCompiler Project

Alt Text

Sample input:

a = 1;
for (b = 2 : 10){
  a = a * b + 2;
  print a;
}

Grammer:

program: statements ;

statements: (statement)+ ;

statement: identifier = expr;
        | { statements }
        | 'if' ( expr ) statement
        | 'if' ( expr ) statement 'else' statement
        | 'while' ( expr ) statement
        | 'for' ( identifier = number : number ) statement
        | 'print' identifier;
        ;
		
expr: expr binop expr
		| '!' expr
		| opneParan expr closeParan
		| identifier
		| number
		| boolea
		| complexExp
		; 

complexExp	: div_multi ( plus_minusOP div_multi )* ;
div_multi	: pow  ( div_multiOP pow )* ;
pow 		: fact ( power fact )* ;
fact		: ( complexExp )
				| identifier
				| number
				;

plus_minusOP : '+' | '-'; 
div_multiOP  : '/' | '*';
power		 : '^' ;
binop 		 : '<' | '>' | '<=' | '>='  | '==' | '!=' ;

thanks to @Benny Coder on youtube for UI and dragger code 😄

About

JavaFX SimpleCompiler Project

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published