bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GLR: modification of $1


From: Frank Heckenbach
Subject: GLR: modification of $1
Date: Thu, 2 Oct 2003 01:45:56 +0200
User-agent: semail 20030730

Perhaps a stupid question, but are the `$1' etc. variables read-only
(in particular, in mid-rule actions)? I've always thought they
weren't. The examples in the documentation don't seem to modify
them, but other parsers do (e.g., the gcc C parser does so for
handling `&&' etc.).

If modification is actually allowed, there seems to be a bug in the
GLR parser (tested with 1.875b since I can't easily build the CVS
versions).

The attached program gives me the following output:

: yynormal = 0
: &$1 = -1073755536
: $1 = 5
: new $1 = 42

This is from the mid-rule action. Here the parser is split
(yynormal = 0). The semantic value $1 is 5, as returned by yylex,
and we change it to 42.

: yynormal = 1
: &$1 = 134529328
: $1 = 5

This is the second action after the parser is merged again (the
alternative parser disappeared).

As the output shows, the address of $1 changed, and the value is
reset to the original value. (This also happens if the parser is
still split here, e.g., by removing the 'e' in the parser and in
yylex.)

Frank

-- 
Frank Heckenbach, address@hidden
http://fjf.gnu.de/
GnuPG and PGP keys: http://fjf.gnu.de/plan (7977168E)

Attachment: demo.y
Description: Binary data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]