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.
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Parsing state of the art and ANTLR 4 demo using intellij plugin
1. Computer Language Design and
Implementation meetup March 6, 2014
Latest and greatest
parsing stuff
Terence Parr
University of San Francisco
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. 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. 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. 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. ALL(*) vs X speed parsing Java
12,920 Java files, 3.6M lines, size
123M.
7. Time and space to parse and optionally build trees.
Single 3.2M Java file
10. Demo: let’s build Valgol
From “Valley girls” in 1980s
def f(x,y) {
code: https://github.com/parrt/antlr4-demo-simple-lang
plugin: http://plugins.jetbrains.com/plugin/7358?pr=
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
}