help-bison
[Top][All Lists]
Advanced

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

Reading parser stack


From: Mark Redd
Subject: Reading parser stack
Date: Wed, 29 Apr 2009 13:23:22 +0200

Hello everybody,
I would like to receive an hint about reading parser stack.

Suppose my (fantasy) bison grammar is this:

%start A

A : B C D | B E D

B: ID
C: '*'
D:  IDENTIFIER
E: '-'

where IDENTIFIER has been defined like [a-zA-Z0-9]+ using flex.

How can I print "the identifier was: %s" when C matches (but not when E does
it) without rewriting the grammar?
In particular, I need to know what I have to write in
C: '*'        { printf("The identifier was: %s", ?????); }

Note that it isn't my very problem, but it's a model of this and so I'd like
a general answer. So I can't modify my grammar and I don't want to read only
the last token in parser, but sometimes I'm interested in reading the last n
tokens.

Thank you!
Mark Redd


reply via email to

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