FreeBSD Port: byaccj-1.1

Raúl Izquierdo Castanedo raul.izquierdo at
Mon Mar 21 08:06:23 PST 2005


I'm Raúl, Professor at University of Oviedo (Spain) where I teach
Compiler Construction.
After using PCLex/Pcyacc during many years I decided to change them
and after checking several tools I decided to use  byaccJ.

I write you because I think something goes wrong when generating the
parser in Java (no problem in C++).
First of all I assure you that I've tried to solve the problem for myself:
- I have checked the samples generating C/C++ with byacc and with
other LR tools. All of them where right with the same input grammar
except ByaccJ.
- I've searched in Google for a solution. Nothing found.

¿Could this be a bug?

1) The first sample is (I include a ZIP with complete files to run)

inicio: expr { System.out.println($1.ival); }
expr: '+' CTE expr { $$.ival = $2.ival + $3.ival; }
            |  {$$.ival = 0; }

When I run it a "Null pointer exception" is throw. When it tries to
access the stack to get the semantic values ($n) it seems to get a
null pointer from the stack.

2) The second sample is:

inicio: expr { System.out.println($1.ival); }
expr: CTE moreTerms { $$.ival = $1.ival + $2.ival; }
moreTerms: '+' CTE moreTerms { $$.ival = $2.ival + $3.ival;
System.out.println($2 == $3); }
  |   { $$.ival = 0; }

I think it's another view of the same bug. Now the program runs
without exceptions, but the final result is wrong. There is a problem
with the $s.
Sometimes $2 and $3 reference the same ParserVal instance (see the
System.out.println($2 == $3) ).

Could you please help me? If I don't find a solution I will have to
select another tool and I think it byaccJ is the best.

Thanks in advance
Ps: I assure you that this translation from spanish hasn't been made
automatically by Google. ;)

More information about the freebsd-ports mailing list