Simple JavaScript Lexer/Parser based on the 'dragon book'

This is something of a learning exercise to understand the concepts of Compilers: Principles, Techniques, and Tools. Currently, the lexer does not use the NFA techniques of the book - it uses iterative matching of native JavaScript regular expressions. There are two parses - a simple one based on iterative pattern matching of the production expressions (supporting precedence), and an automaton based on SLR (supporting precedence and associativity).

For the trivial time-unit-dsl expression langauge I've been testing with, regex hacking was a lot faster and easier (one evening) than the full fledged automaton techniques of the book (a couple of weekends) However, I did finally get it working, and it the resulting parser passes the - probably very insufficient - set of tests I threw at it. It operates off of data structures, and additional grammars can be fed in to parse additional languages. Over time, I expect to add at least one language for testing - SillyScript - and try out other parse construction methods.

Other methods I know of

Know Bugs

  • The simple parser doesn't support associativity
  • 'Unit Tests' are sorely lacking
  • Precedence assignment is implicit; overrides are possible but are fragile and require understanding the implicit assignment algorithm.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.