A simple parser for python made using lex yacc. It currently supports only selected python expressions as stated below.
- gnu's lex yacc
sudo apt-get install bison flex - make utility
sudo apt-get install build-essential
- go to source folder
cd src make cleanto remove old stuff lying aroundmaketo build : this will generate the usual filesmake runto execute
- go to source folder
cd src make cleanto remove old stuff lying aroundmake debugto build with debugging flags- this will generate a lot of extra files. feel free to look through.
make runto execute
- each statement ends with semicolon
-
arithmetic expressions along with brackets
a=5; a=5+24; a=rod; a=5*(4+3);
-
string assignments
var="hello"; var='hello';
-
print statements
print 'hello'; # single quotes handled print "hello"; # double quotes handled
-
keywords cant be identifiers
-
Multiple Statements on a Single Line
var=5; var2=6; var7=23;
-
multi line statements -- a single statement written in multiple lines
var= 2+ \ 3+ \ 4
-
static array initialisation not included
var = [3,3,23]; days = ['Monday', 'Tuesday', 'Wednesday','Thursday', 'Friday']
-
single or multi line comments
-
triple quote print statements - multiline strings
print """hello"""; print '''hello'''; -
typecasting
print "hello" + str(5);
-
shorthand operators not handled
var+=3; var+=2;
- This assignment covers only simple cases.
- Only to be used as a reference point.
- This code was made in 2015. Use at your own discretion.