Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Parsing state of the art and ANTLR 4 demo using intellij plugin


Published on

Quick discussion of attempts to increase top-down parsing strength and a demo of ANTLR 4 using the Intellij plugin. The demo language is Valgol, derived from "Valley girl" speak from 1980s. Hilarious. Speed comparison of ANTLR to many other tools when parsing Java.

Published in: Technology
  • Be the first to comment

Parsing state of the art and ANTLR 4 demo using intellij plugin

  1. 1. Computer Language Design and Implementation meetup March 6, 2014 Latest and greatest parsing stuff Terence Parr University of San Francisco
  2. 2. Believe it or not... ● I think I have built my last parser generator ● ``Why program by hand in 5 days what you can spend 5 years of your life automating?’’ ^ 2
  3. 3. The great struggle ● Top-down (LL), bottom-up (LR,GLR) have duked it out for a long time ● LL(k) much weaker than GLR as GLR can take any grammar ● LL is O(n), GLR is “O(n^3)” ● Some worked on increasing LL strength ● Others worked on optimizing GLR for speed
  4. 4. Increasing LL strength ● ● ● ● All about the lookahead 1990: LL(k) for k>1 1994: limited backtracking (syn. predicates) 2004: PEG: parser expression grammars formalized syn preds. Key addition: memoize partial parsing results to get O(n); ● 2007: ANTLR 3 LL(*) ● 2010: GLL; any grammar but O(n^3)
  5. 5. 2012: ANTLR 4 ALL(*) ● ● ● ● ● Any grammar w/o indirect left-recursion Can tweak grammar to make very fast Auto constructs parse trees Generates listeners and/or visitors Good doc (if you have $25)
  6. 6. ALL(*) vs X speed parsing Java 12,920 Java files, 3.6M lines, size 123M.
  7. 7. Time and space to parse and optionally build trees. Single 3.2M Java file
  8. 8. Listener events
  9. 9. Depth-First Search of parse tree, firing events
  10. 10. Demo: let’s build Valgol From “Valley girls” in 1980s def f(x,y) { code: plugin: var z = grody^max gag me with a spoon totally do antlr = like bitchen for i = like 1 to maybe 10 totally do x = fersure tubular }