[Top][All Lists]

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

Re: passing down value of terminal

From: Hans Aberg
Subject: Re: passing down value of terminal
Date: Wed, 22 Nov 2006 20:00:16 +0100

On 22 Nov 2006, at 19:41, vlad florentino wrote:

In gnu bison:

I have a couple of productions of this type:
ID '.' complex
 : {...}

 : FOOBAR  {...}

How can I pass the value of ID, a terminal, down to the production
'complex', a non terminal. I would like to determine what's the value of ID
and take actions based on that, i.e.:
   if( strcmp(ID.value,"this") == 0)

You can't within the parser itself, as it is a bottom-up parser; so some trick is needed. So either use variable global to the parser, or write it in the action of the first rule you have above (using $1). You might also attempt using negative $k numbers (perhaps $-1 in your case), but that is tricky: for one, thing, it will break if you variable "complex" is used in some other context.

  Hans Aberg

reply via email to

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