This interpreter allows you to write code that performs addition, multiplication, order of operations, parenthesis, function definition and function calling with arguments for non-negative integers
Every program must:
- Must define MAIN()
- DEF MAIN { A(1) } ; //valid main function
- DEF A x { x+1 } ; //valid function with parameter
- FUNCTION NAMES ARE UPPER CASE
- parameters are lower case
1.0,2.1,-3are invalid numbersminus, divisionare invalid operations- Functions being called must be defined
- Interpreter can detect infinite left and right recursion and prints
DIVERGENCE
to stdout
- Javacc (Put in same file as Interpreter.jj)
- Java
- Create interpreter:
javacc-6.0/bin/javacc Interpreter.jj
- Compile java classes:
javac *.java
- Run test files:
java Interpreter < tests/validFiles.txt
- Your code just got interpreted and if its valid, the result will be displayed!