[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Including the name of a rule in an action
From: |
Joel E. Denny |
Subject: |
Re: Including the name of a rule in an action |
Date: |
Sun, 31 Jan 2010 17:58:38 -0500 (EST) |
User-agent: |
Alpine 1.00 (DEB 882 2007-12-20) |
On Sat, 30 Jan 2010, Tom Stellard wrote:
> I am currently using: yytname[yyr1[yyn]] to access the name of the
> rule that each action is associated with. For example:
>
> program: classes { printf("rule: %s\n",yytname[yyr1[yyn]]);}
> ;
>
> Is this the recommended way to do this,
As far as I know, yyr1 is not documented for users, so there's no
guarantee it will be supported in future versions of Bison.
> or is there a better way?
None that I know of. Can you tell us a little more about why you need to
do this? That is, why doesn't the following suffice for you?
program: classes { printf("rule: program\n");}