]> thyrsus.com Git - intercal.git/commit
Jonathan Nieder's spark-precedence fix.
authorEric S. Raymond <esr@thyrsus.com>
Sat, 26 Feb 2000 00:36:00 +0000 (19:36 -0500)
committerEric S. Raymond <esr@thyrsus.com>
Thu, 26 Aug 2010 00:34:26 +0000 (20:34 -0400)
commit983236c6530f92b21d266216c0df7ab52f220310
tree518be56712d47da445972048c668c1e8a3840168
parent8b82684d1a11304fae6cffebf1b81142b798e4c8
Jonathan Nieder's spark-precedence fix.

From jrnieder@hotmail.com  Fri Feb 25 11:00:42 2000
Date: Fri, 25 Feb 2000 21:21:03 -0800
From: Jonathan Nieder <jrnieder@hotmail.com>
X-Mailer: Mozilla 4.7 [en] (Win95; I)
To: esr@thyrsus.com
Subject: Intercal Bugfix

can be fixed quite easily (in code changes; not in that search for
the problem, though).  I'm not sure about side effects of my
solution.  It's not very well-tested.  But, the following program
compiles and does the right thing:

PLEASE ,1 <- #1 BY #1
DO ,1 SUB #1 #1 <- #0
DO WRITE OUT ,1 SUB #1 '#1'

So, it must fix the bug.  Here's the deal.  As bison parses that
third line, it eventually ends up with an unambig on the stack
and a spark in look-ahead.  It wants to know whether it should
"reduce" the unambig to a sublist1 or to continue parsing and
hope for a unambig followed by a new sublist1.  This particular
reduction has the prescedence of the (fake) token HIGHPREC.
HIGHPREC, in this particular grammar, has the highest prescedence
possible.  Since it has higher prescedence than the look-ahead
token, bison reduces, and it is straightforward from there to
parse the DO WRITE OUT ,1 SUB #1 as a command.  It then goes
on the parse the new "command" after it, and it can't even
find a DO to make into a "please".  Since programs can only
be lists of commands, it of course signals an error.

So, to fix it, simply switch the command (on line 103 of ick.y)
        %nonassoc HIGHPREC
with the command (on line 102)
        %nonassoc EARS SPARK

So, change
        %nonassoc EARS SPARK
        %nonassoc HIGHPREC
to
        %nonassoc HIGHPREC
        %nonassoc EARS SPARK

Then recompile and enjoy a new ick that has THAT problem fixed...
It's such a trivial change that I decided not to include a contextual
diff.

Hope this helps INTERCAL to suck in even more programmers' time...
src/BUGS
src/ick.y