[gnu.bash.bug] function foo { echo foo; } doesn't parse right

nickson@comp.vuw.ac.nz (Ray Nickson) (08/07/89)

help function appears to claim that the above syntax is a legitimate
function definition, but bash (1.02, gcc-compiled, BSD on an HP300,
not that it matters) claims that there is a `syntax error near `{''.
The problem appears to be that although the yacc parser has a separate
production for this case, the lexer never allows it to see a `{'
unless it occurs immediately after a `()' pair.

An (unrelated) bug which doesn't cause any problems is in
`reserved_word_acceptable'; this is declared to take an argument,
which it completely ignores.  I wonder whether some minor attention
could result in a significantly cleaner, easier to understand lexer
and parser.

-rgn
--
Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand.
nickson@comp.vuw.ac.nz       ...!uunet!vuwcomp!nickson      + 64 4 721000x8593

bfox@AUREL.CALTECH.EDU (Brian Fox) (08/08/89)

   Date: Mon, 07 Aug 89 11:21:10 +1200
   From: Ray Nickson <nickson@comp.vuw.ac.nz>

   help function appears to claim that the above syntax is a legitimate
   function definition, but bash (1.02, gcc-compiled, BSD on an HP300,
   not that it matters) claims that there is a `syntax error near `{''.
   The problem appears to be that although the yacc parser has a separate
   production for this case, the lexer never allows it to see a `{'
   unless it occurs immediately after a `()' pair.

Thanks, fixed.

   An (unrelated) bug which doesn't cause any problems is in
   `reserved_word_acceptable'; this is declared to take an argument,
   which it completely ignores.

That was preparation for the future, and the future took place after
1.02 but before 1.03.

   I wonder whether some minor attention could result in a significantly
   cleaner, easier to understand lexer and parser.

If you would like to write a "significantly cleaner, easier to
understand" parser, by all means, please do!  I would be glad to
include/use any code which I find to be clean, especially if it is
cleaner than what is already in use.

Brian