Path: utzoo!mnetor!uunet!pilchuck!ssc!markz From: markz@ssc.UUCP (Mark Zenier) Newsgroups: comp.unix.microport Subject: Re: YAMB: problems with yacc? Message-ID: <1107@ssc.UUCP> Date: 21 Mar 88 20:20:37 GMT References: <437@splut.UUCP> Organization: SSC, Inc., Seattle, WA Lines: 38 Keywords: won't do hoc1 right Summary: Try this In article <437@splut.UUCP>, jay@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.