A barebone Ruby Interpreter implemented in JAVA
- Java SDK
- Arithmetic Expression Evaluation
- Operators
- Arithmetic Operators
- Addition with String Concatination (+)
- Subtraction (-)
- Multiplication with String Replication (*)
- Division with floating point and integer(/)
- Exponentiation (**)
- Logical Operators
- and (and, &&)
- or (or, ||)
- Arithmetic Operators
- Variable Assignment 1
- Parallel Assignment (a=b=1)
- Print Statement
- Puts Statement
- Global Variables
- Constant Variables
- Control Statement
- If Statement
- If-Else Statement
- If-Elsif Statement
- Unless Statement
- Unless-Else Statement
- Looping Statements
- While Statement
- Until Statement
- Loop Statement
- For Statement without step 2
- Loop Control Statements
- Break Statement
- Next Statement
- Functions Without Closures 3
- Comments
- Single-line Comments
- Multi-line Comments using =begin and =end
First, we read the file or the data fed into the interpreter, now this data is passed to the scanner The raw source file is now tokenized in the scanner, The scanner returns a list of tokens The tokens are now passed to the parser, The parser reads the tokens, and systematically builds a syntax tree from the ground up using the recursive decent style parsing
Now the generated statements/expressions are then finally passed on to the interpreter for the final interpretation. Now the interpreter in short uses the visitor method to find the type of each statement and expression, It then uses the declared methods to interpret the syntax tree and execute the instruction in Java
- Absence of semicolon
- Parallel Assignment
- Scope issues 4
- Closure issues
- 0 arguments passing in functions
- too much alternatives to do the same thing in Ruby
- Exponent with negative power
- figuring out how to implement an iterator for 'for' loop
- BNF usage
- Lexical analysis
- learnt to differntiate between differnt lexemes
- learnt to create tokens from source code
- Parsing
- learnt recursive decent parsing style
- learnt to generate parse tree
- learnt how the type data of one language can be implemented in another language that is interpreting it
- learnt to implement operator precedence
- Interpretation
- learnt to use visitor pattern
- learnt how functions can be handled
- learnt how a interpreter works in the backend
- Sonith :
- variable assignment
- environment
- if, unless, case statements
- error handling
- Akilesh :
- functions
- parser base
- error handling
- Shivadharshan :
- Scanner
- Tokens
- base Expr
- arithmetic operators
- exponent
- multiline comment
- bug fixes
- error handling
- Mokshith and Sasaank :
- loop
- until
- while
- for
- range
- break
- next
- modulo
- error handling