It is Built with Flex and Bison.
This is a compiler project designed for Compiler Design course.
https://github.com/ArafatRohan93/Compiler-H
- Calling Main Function
void_main ( )
{{ ... }}
- Statement Terminator
<br>
- Declaring Variables
$_int_$ a:=50
- Operators
Symbol | Action |
---|---|
:= | Assignment |
^ | Power |
+ | Plus |
- | Minus |
* | Multipliation |
/ | Division |
> | Greater Than |
< | Lesser Than |
== | Is Equal |
>= | Greater or Equal |
<= | Lesser or Equal |
!= | Not Equal |
! | Factorial |
- Scope Resolution Operator
Symbol | Action |
---|---|
{{ | Start of scope |
}} | End of scope |
- if-else Supports Nested if properties
if (1):
{{ 5 }}
else:
{{ 7 }}
if (2 > 3):
{{ 1 }}
else:
{{
if (0):
{{ 5 }}
else:
{{ 7 }}
}}
- Loops
- For Loop
for ( x := 0 , x <= 4, x ++ )
{{
print(5) <br>
}}
- While Loop
while(i<5):
{{
z<br>
i++<br>
}}
- Function
- Declaration Must be inside Main()
return_type function name()
{{
...
}}
Example :
$_int_$ function oddeven1 ( )
{{
13 <br>
}}
- Calling Function
function oddeven1 ( )
- First install Flex and Bison on your machine.
1.Open Command prompt and switch to your working directory where you have stored your lex file (“.l“) and yacc file (“.y“).
2.Let your lex and yacc files be “rhn.l” and “rhn.y“. Now, follow the preceding steps to compile and run your program.
- For Compiling Lex file only:
flex hello.l
gcc lex.yy.c
- For Compiling Lex & Yacc file both:
flex hello.l
bison -dy hello.y
gcc lex.yy.c y.tab.c
- For Executing the Program
a.exe