PacktPublishing / Build-Your-Own-Programming-Language

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

Chapters 5/6 unicon version of j0 parser does not run #2

Open rkanagy opened 2 years ago

rkanagy commented 2 years ago

In chapters 5 and 6, so far, when I run the unicon version of the j0 compiler using the hello.java file as input, I receive an error during the parse.

Here is the command-line I run on Ubuntu Linux 21.10 with KDE:

./j0 hello.java

and this is the error messages that I receive:

Run-time error 102 File j0gram.y; Line 30 numeric expected offending value: tree_11 Traceback: main(list_1 = ["hello.java"]) yyparse() from line 9 in j0.icn action_21() from line 581 in j0gram.icn {tree_11 = tree_14} from line 30 in j0gram.y

I even ran the compiler/parser in debug mode, but it did not give me any useful information.

It seems to be failing on lines 28/29 of the j0gram.y file:

VarDeclarator: IDENTIFIER | VarDeclarator '[' ']' { $$=j0.node("VarDeclarator",1060,$1); };

The java version of the parser for j0 runs fine.

Does anyone have any ideas on how to fix this?

rkanagy commented 2 years ago

FYI, I built the unicon and java parsers for chapter 7, and now the unicon parser is working. I will compare the grammars from chapters 5/6 with chapter 7 and see what the differences are.

cjeffery commented 2 years ago

Thank you for this report. Assuming all turns out as reported, I will apply a comparable fix to the Ch5-6 code as was apparently made during the development of Ch7.