You will develop a mini-interpreter of a modern programming language. The input source code will be: Python. You will create a program to evaluate list expressions, with array-based lists (i.e. the default list mechanism).

computer science

Description

1 Introduction 

You will develop a mini-interpreter of a modern programming language. The input source code will be: Python. You will create a program to evaluate list expressions, with array-based lists (i.e. the default list mechanism). There will also be simple arithmetic expressions. Since Python and JavaScript are without doubt two dominating languages today, input files will have list manipulation code that will be as similar as possible between both languages, other than minor syntax changes or different function names. In other words, the knowledge you have on JavaScript or some other dynamic language does help you solve this homework. This “interpreter” program will be developed in C++ (but pure C is also acceptable). Notice some other language like Java, JavaScript, Ruby and Python itself are not acceptable since their libraries do 90% of the work and you learn nothing. Theory in practice: Your program will use regular expressions to recognize identifiers (var/function names), numbers and strings. Your program will implement a simplified context-free grammar to recognize arithmetic expressions with ’+’ (which may involve lists or integers). In order to detect and check data types you will have to perform evaluation using an attribute grammar to extend the parse tree. Your program has to evaluate the code, line by line, exactly like the interpreter, but your program does not have to generate intermediate or object code.

Instruction Files
hw2out.pdf
93.6 KB

Related Questions in computer science category