-
Source Language: Python3
-
Target Language: x86 Assembly
-
Implementation Language: Python
-
Authors: Deepak Kumar(13229), Kamesh Kanwariyaa (13336), Palash Chauhan (13455) and Rahul Kumar Wadbude (13533)
-
Tool Used : PLY (Python Lex and Yacc)
- Run the following command to run test1.py
make test=test/test1.py all
- bin:
- lexer.py [Python source file to specify language lexemes]
- parser.py [Python source file to specify grammar]
- yacc.py [Python source file from PLY for parsing ]
- generate.py [Python file to generate rightmost derivation in html ]
- src:
- lexer.py [Python source file to specify language lexemes]
- parser.py [Python source file to specify grammar]
- yacc.py [Python source file from PLY for parsing ]
- generate.py [Python file to generate rightmost derivation in html ]
- test:
- 'test1'.py [Test files]
- 'test2'.py [Test files]
- 'test3'.py [Test files]
- 'test4'.py [Test files]
- 'test5'.py [Test files]
- makefile
- README.pdf
The compiler supports the basic structures of the Programming languages such as assignment , operators , loops ans function calls.
*Note : Indentation is through tabs or spaces
Assignment
a=10
a=10.2
a=b
a=[1,2,3,4,a,b]
Print Statement
print a
print 4
print 4.6
print 'hello world'
print "hello world"
print '''hello world'''
Operators with Parenthesis
c = a + b - c * c / d % k
c=(a+b)**(c+d)
a+=b
a-=c
a*=c
a/=c
a%=c
Relational & Logical Operators
a = 4 > 3
a= 4 > 3 and 5==5
a= a > b or c <= 9 and not True
if True and True:
do something
If Statement
a=9
if a==9:
print 'yes'
a=10
if a == 10:
print 1
else :
print 2
While Statement
while a > 0:
print 'hi'
Nested Looping
while a > 0:
while b >= 0:
while c>=0:
for i in [1,2,3]:
print 'hi'
Function Without Parameters
def myfun():
a=10
myfun()
Function With Parameters
def myfun(c, d, e, f):
print c,d,e,f
a = myfun(1000, 100, 10, 1)
print a
Function call from another function
def f():
return 1
def f1():
f()
Recursion
f():
print 'hi'
if i>1:
f()
Break & Continue Statement
for i in [1,2,3]
a=1
if i==3:
break
else:
continue