Bug in USG Sys V Rel 2 (possibly others) yacc(1)
R. Curtis Jackson
rcj at burl.UUCP
Fri Sep 28 02:28:57 AEST 1984
I just got off the phone with the Unix Hotline after spending 15 minutes
explaining to someone there why this was a bug. It involves the '-l'
and '-t' options of yacc. Refer to the code below, taken from
/usr/src/cmd/yacc/y2.c command-line parsing section (don't think
this will violate any licenses :-) ):
case 'l':
case 'L':
gen_lines = !gen_lines;
case 't':
case 'T':
gen_testing = !gen_testing;
continue;
If you use '-t', you are supposed to turn on compilation of debugging
code (by setting gen_testing, which is initially 0). '-l' is supposed
to suppress the generation of #line directives in the output so you
can use sdb on the compiled y.tab.c (by unsetting gen_lines, which is
initially 1). Because the '-l' option should "only be used after
the grammar and associated actions are fully debugged", the guy who
wrote this apparently realized our human failings and decided to be
nice and let the '-l' option fall through and turn on debugging, so
we wouldn't have to re-yacc when there was a problem. He also neglected
to document this feature (no doubt due to excessive modesty).
Unfortunately (I used to have a professor who would have said that
this was 'intuitively obvious'), the fool used !gen_testing instead
of gen_testing=1, therefore whenever '-l' and '-t' are used in conjunction
you wind up with no debug code compiled in even though you have
specifically requested it via '-t'. Also, when you use '-l' without
'-t', you get debug code when you implicitly refused it by NOT using
'-t'.
Just thought you'd like to know,
--
The MAD Programmer -- 919-228-3313 (Cornet 291)
alias: Curtis Jackson ...![ ihnp4 ulysses cbosgd mgnetp ]!burl!rcj
...![ ihnp4 cbosgd akgua masscomp ]!clyde!rcj
More information about the Comp.unix.wizards
mailing list