parsing - Make the Grammar LL -


i wasted 2 time on converting it, getting common prefix id.

can explain me? trying large grammar , need basics clear.

a, b, c, d non-terminals.

a : ‘(‘ b ‘)’   | id assign c   | c   c : c '+' d   | c '-' d   | d   d : id   | id '(' actuals ')'   | id '(' ')'   | int_lit   | ‘(‘ c ‘)’    b : b ';' | 

in ll, production can't have multiple options starting same terminal, pull common parts shared head, if will. so

d : id   | id '(' actuals ')'   | id '(' ')'   | int_lit   | ‘(‘ c ‘)’  

becomes along lines of

d : d_things_that_start_with_id  | d_things_that_do_not_start_with_id 

where

d_things_that_start_with_id :   id d_things_that_follow_id  d_things_that_follow_id :   epsilon   | '(' actuals ')'    | '(' ')'   d_things_that_do_not_start_with_id :  int_lit   | ‘(‘ c ‘)’  

and on other common lead symbols.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -