]> thyrsus.com Git - intercal.git/commitdiff
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)
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

index a420d3208b2c4afd862a9e67541f55af5de9eb7c..bc3f1943688dc0bbfcd834aab3c711a614890ee4 100644 (file)
--- a/src/BUGS
+++ b/src/BUGS
@@ -72,18 +72,6 @@ BLR = Brian Raiter
    the modified behavior of select's return type depends on this, so
    there's not much we can do about it as things stand.
 
-5) (BLR) An array can't have sparks or ears in its subscript list after the
-   first dimension. That is to say, this:
-
-       DO ,1SUB'#1'#1 <- #0
-
-   works fine, but this:
-
-       DO ,1SUB#1'#1' <- #0
-
-   doesn't parse, and gets treated as a syntax error (thus it is likely
-   to be a problem with the grammar).
-
                        TO DO
 
 1. (ESR) Add more optimization templates, esp. idioms for +, -, *, /.
index 9bb6bbe72120adcde0fe15701c33d75ab87d0612..9f74a6ba477899b358d6246a11edca08ec212d07 100644 (file)
--- a/src/ick.y
+++ b/src/ick.y
@@ -100,8 +100,8 @@ static tuple *splat(void);
 %type <tuple> perform
 %type <numval> please preftype
 
-%nonassoc EARS SPARK
 %nonassoc HIGHPREC
+%nonassoc EARS SPARK
 
 %%     /* beginning of rules section */