Top Down Operator Precedence

Monday, August 06, 2012
By keiji
I have been working on creating a interpreter for my iPad app "StitchSketch".
In my past, I had created an interpreter a couple of times, but it was always C/C++, and never be able to finish it implementing objects etc.

However, this time, I'm using JavaScript, and found good articles about it, and successfully done implementing OO aspect of my own language.

This time, also I'm using "Top Down Operator Precedence" algorithm as a language parser, instead of LL or BNF. It is very powerful and meets my requirement.

Here is the list of reference:

  • Top Down Operator Precedence by Douglas Crockford.
    Very nice article and has a sample source code written in JavaScript.
    It explains only a parser (and some code regarding tokenizer)

  • Top Down Operator Precedence by Vaughan R. Pratt
    This is the original article of "Top Down Operator Precedence" by Vaughan R. Pratt, Massachusetts Institute of Technology

  • Top-Down operator precedence parsing by Eli Bendersky
    This is also a nice article to better understand the algorithm

  • How to write a simple interpreter in JavaScript by Peter Olson
    This article on Code Project also is a nice one, and it has some example implementing actual "evaluator" (a module to run as an interpreter) It is simplified version, though.



Reply to

(Max 1000 chars)
Confirmation Key:
Please enter the value displayed in the image.
Send Send