0

I need to create the parser for code with variables, simple conditions, cycles and functions, something like:

f=1;
i=1;
while(i<10){
  f=f*i;
  i=i+1;
}
print(f);

I read a lot of theory, but I didn't find any working example of Lr(1) Parser for code. It's necessary to do it without any parser generators.. Anybody?

Manunich
  • 26
  • 3
  • 1
    Why is it necessary not to user parser generators? An LR(1) parser generally uses a stack and performs *shift* and *reduce* operations. – Willem Van Onsem Apr 07 '15 at 14:39
  • Because it's my homework :D I just need any working example of LR parser and then I'll improve it by adding new features.. – Manunich Apr 07 '15 at 14:44
  • 1
    The book *Modern Compiler Implementation in X* by *Appel* shows rather detailed how to transform a context-free grammar into an LR parser. – Willem Van Onsem Apr 07 '15 at 14:48

0 Answers0