- Notifications
You must be signed in to change notification settings - Fork1
simple python compiler by using flex\bison
License
fadel-hasan/python-compiler
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
compiler for python made using lex yacc /GNU's flex bison.
The current version of this code supportsdefining a function
,defining a class
,calling a function
, various types ofexpressions
,assignment
statements, andif conditions
, in addition to loops such asfor
andwhile
and some other structures such astry
,match
,yield
,global
,nonlocal
,return
,break
,continue
,INDENT
\DEDENT
analysis usingstack
You will needflex
,bison
, andgcc
installed on your machine
$ chmod +x build.sh clear.sh
$ ./build.sh
compiled:compiler
,parser.tab.c
,parser.tab.h
,lex.yy.c
$ ./compiler test.py
$ ./clear.sh
This program is run using the following commands:
bison -d parser.y
- This instruction produces two files:
- parser.tab.h : We use this to include it inside the flex file to read the token
- parser.tab.c : We use this file to make a compiler with the resulting flex file
flex pycompile.l
- This instruction produces lex.yy.c file: We use this file to make a compiler with the resulting bison file(parser.tab.c)
Finally
, to compile flex and bixon, we write this command:
gcc -o<program file name> parser.tab.c lex.yy.c
- This produces .exe file
Note
: Thestack
file is included in order to deal with indentation in a file pycompile.ltest file is : test py
but now is ready to execution ^_____^
About
simple python compiler by using flex\bison
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.