PacktPublishing / Build-Your-Own-Programming-Language

Build Your Own Programming Language, published by Packt
MIT License
200 stars 49 forks source link

Hidden epsilon rule in Stmt #4

Open EDKarlsson opened 2 years ago

EDKarlsson commented 2 years ago

There is a | after ReturnStmt and a | before the IfThenStmt. It doesn't result in an issues when generating the parser but wanted to point it out nonetheless.

https://github.com/PacktPublishing/Build-Your-Own-Programming-Language/blob/b631ce673b16089b4f4c74856d5f7128ccde8a00/ch4/j0gram.y#L41-L42

cjeffery commented 2 years ago

Thank you for this report! I agree that this appears to be a typo rather than an intentional epsilon rule to build an empty Stmt.

mingodad commented 11 months ago

I've just added the grammar https://github.com/PacktPublishing/Build-Your-Own-Programming-Language/blob/master/ch13/j0gram.y to https://mingodad.github.io/parsertl-playground/playground/ an online editor/tester for yacc/lex grammars, select Build your own prog. lang. parser from Examples then click Parse to see a parser tree for the source in Input source.

I hope it'll help anyone working with yacc/lex grammars.

Any feedback is welcome !