[antlr-interest] v4 "Honey Badger" teaser
Kyle Ferrio
kferrio at gmail.com
Thu Dec 29 15:58:07 PST 2011
Excellent. I always thought that it should be possible to support
left-recursion with LL(*) but I did not presume that it would be efficient
or easy or wise. Since I tend to think left-recursively a lot, I am a
happy honey badger, and I parse whatever I want!
Kyle
On Dec 29, 2011 4:24 PM, "Terence Parr" <parrt at cs.usfca.edu> wrote:
> Hi, For those of you secretly playing with v4 using the repository, don't
> forget that you can use left recursive expression rules now. These are not
> only faster at runtime, they are easier to specify. ANTLR unravels it to
> nonrecursive rules they use semantic predicates to compare operator
> precedence. Here's a sample expression rule for the R language. Believe it
> or not, that crap works in a top-down parser generator. Oh, and there is no
> such thing is parser backtracking a more. The new adaptive LL(*) simply
> makes all the right choices without backtracking in the prediction or in
> the parser.
>
> v4 code name: Honey Badger, after The Crazy Nastyass Honey Badger:
>
> http://www.youtube.com/watch?v=4r7wHMg5Yjg
>
> It's hilarious if you haven't seen it. "ANTLR v4 doesn't care. It's bad
> ass." ;)
>
> Ter
> ------------
> expr : '{' exprlist '}'
> | '(' expr ')'
> | expr '[[' sublist ']' ']'
> | expr '[' sublist ']'
> | expr ('::'|':::') expr
> | expr ('$'|'@') expr
> | expr '^'<assoc=right> expr
> | ('-'|'+') expr
> | expr ':' expr
> | expr USER_OP expr
> | expr ('*'|'/') expr
> | expr ('+'|'-') expr
> | expr ('>'|'>='|'<'|'<='|'=='|'!=') expr
> | '!' expr
> | expr ('&'|'&&') expr
> | expr ('|'|'||') expr
> | '~' expr
> | expr '~' expr
> | expr ('->'|'->>'|':=') expr
> | expr ('<-'<assoc=right>|'<<-'<assoc=right>) expr
>
> | 'function' '(' formlist ')' expr
> | expr '(' sublist ')'
>
> | 'if' '(' expr ')' expr
> | 'if' '(' expr ')' expr 'else' expr
> | 'for' '(' ID 'in' expr ')' expr
> | 'while' '(' expr ')' expr
> | 'repeat' expr
>
> | '?' expr
>
> | 'next'
> | 'break'
>
> | ID
> | STRING
> | HEX
> | INT
> | FLOAT
> | COMPLEX
> | 'NULL'
> | 'NA'
> | 'Inf'
> | 'NaN'
> | 'TRUE'
> | 'FALSE'
> ;
>
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list