Top Down Operator Precedence

Douglas Crockford



This is the companion file to my paper on Vaughan Pratt's Top Down Operator Precedence. The paper presents a parser for Simplified JavaScript that is written in Simplified Javascript. It is chapter 9 of Beautiful Code. This page loads that parser and runs the parser on itself.

This page loads two JavaScript files:

tokens.js This file installs the tokenize function. It produces an array of simple tokens from a string or array of strings.
parse.js This file installs the make_parse function which produces the parse function. The indirection was done so that we could conveniently recover the source of the function.

The text that follows is the parse tree that the parser generated by parsing itself.