Recursive Descent Calculator
Coder100 (6236)

Recursive Descent Calculator

This is a recursive descent calculator. It uses recursion to both interpret and parse the input. The lexer is just a for loop.

Languages used

bash for the running and node for the logic


The code should be pretty self-explanatory, but it comes from here and here.


Bad tutorial

  1. Lexer: Loop through each character of the code and look for things accordingly
  2. Parser: Given a grammar, convert it to javascript. Then, use the definition of lowest precedence to use recursion to go down/up.
  3. Interpreter: Recursively evaluate the tree.

I think the code will help more.


I hope this helps you with your language! It certainly taught me a lot!

Have a great day


You are viewing a single comment. View All