Skip to content

yagna-bork/Interpreter

Repository files navigation

Interpreter for non-negative arithmetic

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

Syntax

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,-3 are invalid numbers
  • minus, division are invalid operations
  • Functions being called must be defined
  • Interpreter can detect infinite left and right recursion and prints DIVERGENCE to stdout

How do I run it?

Dependencies

  • Javacc (Put in same file as Interpreter.jj)
  • Java

Steps

  1. Create interpreter: javacc-6.0/bin/javacc Interpreter.jj
  2. Compile java classes: javac *.java
  3. Run test files: java Interpreter < tests/validFiles.txt
  4. Your code just got interpreted and if its valid, the result will be displayed!

About

Interpreter for non-negative arithmetic

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy