help-bison
[Top][All Lists]
Advanced

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

RE: Contional productions


From: Ramaswamy R - TLS, Chennai.
Subject: RE: Contional productions
Date: Mon, 10 Jul 2006 14:42:29 +0530

No that ain't possible because bison generated code is fixed for a set of
productions

If you need to perform based on certain conditions, then I'd suggest
splitting the parser into multiple parts. Let us call the construct you want
to parser differently based on a condition as CONSTRUCT and the two ways of
parsing it as PARSE1 and PARSE2

The base parser will have a generic mechanism to parse CONSTRUCT regardless
of how it is to be parsed. This parser will assimilate this into a text
stream and pass it to either of PARSE1 or PARSE2 based on the situation.

This is the worse case if the decision can arbitrarily toggle between PARSE1
and PARSE2 (condition not dependent on parser input).

But if the same program is to behave differently depending on input then you
could fabricate some special token in you lexer and fabricate the grammar to
act differently depending in the presence or absence of the token (linked to
the state of the flag).

We would give a much better solution if you be a little more specific as to
what governs the decision as to which way to parse.

Regards
Ramaswamy


-----Original Message-----
From: address@hidden
[mailto:address@hidden On Behalf Of
Vidhya
Sent: Monday, July 10, 2006 12:58 PM
To: address@hidden
Subject: Contional productions

Hi All

Can I write conditional productions based on a flag .

I have a normal production ,then inside the action part I determine the
value of the flag .

After that I  want the productions itself to be controlled by this flag 



reply via email to

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