Skip to content
Back to formatted view

Raw Message

Message-ID: <49C8A7AF.2040201@idi.ntnu.no>
Date: 2009-03-24T09:28:15Z
From: Wacek Kusnierczyk
Subject: If statement generates two outputs
In-Reply-To: <49C8A180.9010709@dbmail.com>

Romain Francois wrote:
> This is probably due to that in the gram.y file :
>
> case ':':
>    if (nextchar(':')) {
>        if (nextchar(':')) {
>        yylval = install(":::");
>        return NS_GET_INT;
>        }
>        else {
>        yylval = install("::");
>        return NS_GET;
>        }
>    }
>    if (nextchar('=')) {
>        yylval = install(":=");
>        return LEFT_ASSIGN;
>    }
>    yylval = install(":");
>    return ':';
>    which gives a meaning to ":=", so that parsing x := 2 makes sense.
>
> > parse( text = "x := 2" )
> expression(x := 2)
> attr(,"srcfile")
> <text>

thanks.  so it seems to be intentionally parsable, though i wouldn't say
that this gives a meaning to ':=' -- the operator has a syntactic
category, but no semantics.  the syntactic category does not imply any
semantics, as in

    '<-' = function(a, b) NULL
    1 <- a
    # NULL

where '<-' is still parsed the original way (as a LEFT_ASSIGN, gram.y
again), but has now a completely different semantics.

it looks like a bug to me:  ':=' is parsed on par with '<-' as a
LEFT_ASSIGN, but apparently is not backed by any function.  it's a
zombie.  (unless rvalues is used, that is.)

vQ