YAMB: problems with yacc?

Mark Zenier markz at ssc.UUCP
Tue Mar 22 06:20:37 AEST 1988


In article <437 at splut.UUCP>, jay at splut.UUCP (Jay Maynard) writes:
> I tried entering the program hoc1, from the book _The Unix Programming
> Environment_, and compiling it last night. It doesn't run: when fed an
> expression like 2+2, instead of printing 4, it prints 2. It appears to
> reproduce productions of the form:
> expr: expr '+' expr { $$ = $1 + $3 }...
> ...
> Am I bashing my head against YAMB (yet another Microport bug)?
> ...
> Jay Maynard, EMT-P, K5ZC...>splut!< | GEnie: JAYMAYNARD  CI$: 71036,1603
> ...


Having written 8 cross assemblers, a database screen compiler and mucked with
a spreadsheet, I'm pretty sure that Yacc on Microport is clean. (Plug, Plug)

It sounds like Yacc is interpeting your action as an imbedded one.

"Actions that do not terminate a rule are actually handled by yacc by 
manufactureing a new nonterminal ..."

The next stuff after the closing } needs to be a semicolon or
a vertical bar.  

example

expr : expr '+' expr
	{ $$ = $1 + $3; }
    ;  

or

expr : expr '+' expr
	{  $$ = $1 + $3 }
    |  expr '*' expr
	{  $$ =    ... and so on

Mark Zenier, Specialized Systems Consultants, Inc.



More information about the Comp.unix.microport mailing list