mercredi 14 mai 2014

Are there any good LL(k) parser examples?


Vote count:

0




In the appendices of the Dragon-book, a LL(1) front end was given as a example. I think it is very helpful. However, I find out that for the context free grammar below, a at least LL(2) parser was needed instead.



statement : variable ':=' expression
| functionCall

functionCall : ID'(' (expression ( ',' expression )*)* ')'
;
variable : ID
| ID'.'variable
| ID '[' expression ']'
;


How could I adapt the lexer for LL(1) parser to support k look ahead tokens? Are there some elegant ways?



asked 36 secs ago






Aucun commentaire:

Enregistrer un commentaire