lalr


Convert LALR to LL


I have this (working) LALR grammar for SABLECC:
Package org.univpm.grail.sable;
Helpers
digit = [ '0' .. '9' ];
letter = [ [ 'a' .. 'z' ] + [ 'A' .. 'Z' ] ];
any_character = [ 0 .. 0xfffff ] ;
States
normal, complex;
Tokens
newline = ( 13 | 10 | 13 10 ) ;
blank = 32+ ;
dot = '.' ;
comma = ',' ;
element = 'v' | 'V' | 'e' | 'E' | 'all' | 'ALL' ;
cop = '>' | '<' | '>=' | '<=' | 'like' | 'LIKE' | '==' | '!=' ;
number = digit+ | digit+ '.' digit digit? ;
l_par = '(' ;
r_par = ')' ;
logic_and = 'and' | 'AND' ;
logic_or = 'or' | 'OR' ;
logic_not = 'not' | 'NOT' ;
id = ( 95 | letter ) ( letter | digit )+ ;
line_comment = '/' '/' [ any_character - [ 10 + 13 ] ]* ( 13 | 10 | 10 13 ) ;
string = '"' letter* '"' ;
Ignored Tokens
blank;
Productions
phrase =
{instruction} instr |
{complex_instruction} instr newline+ phrase? ;
instr = command query ;
command =
{identifier} id |
{complex_identifier} id l_par parlist r_par ;
parlist =
{complex_parlist} par comma parlist |
{simple_parlist} par ;
par =
{numero} number |
{stringa} string |
{idpar} id ;
query =
{query_or} query logic_or term |
{query_term} term ;
term =
{term_and} term logic_and factor |
{term_factor} factor ;
factor =
{atop} attroperator |
{query_not} logic_not attroperator |
{query_par} l_par query r_par ;
attroperator =
{simple_element} element |
{complex_element} element dot id cop par ;
I was trying to convert it for XText that uses ANTLR (LL parser generator). I'm having trouble converting this two left-recursive rules:
query =
{query_or} query logic_or term |
{query_term} term ;
term =
{term_and} term logic_and factor |
{term_factor} factor ;
How should I do it? I think I should work with operator precedence but rigth now I can't just think in a LL way.
Well, I finally did it with this guide:
http://javadude.com/articles/lalrtoll.html
I had to solve left recursion

Related Links

Convert LALR to LL

Categories

HOME
eclipse
scikit-learn
facebook-oauth
phpmyadmin
composite-primary-key
iis-6
fhir
mvc-mini-profiler
google-content-api
boost-icl
charles
breadth-first-search
imagemap
visual-studio-extensions
event-store
anki
python-2.6
complex-numbers
weather
linkedhashmap
sharding
engine.io
jpad
reactivekit
password-protection
apns-php
chef-solo
datacachefactory
branching-and-merging
naming
smoothstate.js
wc
show-hide
x++
vaadin-elements
pom.xml
xbmc
term
activeperl
insight
openblas
magic-draw
boxing
truezip
cronexpression
actor-platform
nikeplus-api
ng-grid
dimension
clipboard.js
stream-processing
deep
nss
bizagi
cortex-m
fink
aspen
false-sharing
contentcontrol
state-restoration
concurrentmodification
sciruby
wiredep
django-urls
fuelcms
zen-cart
viola-jones
skspritenode
user-permissions
broadband
bcache
viewer
android-vibration
malformedurlexception
ios8-extension
vsx
twitter-bootstrap-rails
gae-quotas
rolify
octal
android-icons
virtual-pc
preload
robotlegs
thttpd
floating-point-exceptions
jqote
umra
aspmenu
web-garden
interop-domino
technical-debt
commercial-application

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App