[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison and an one-parse interpreter
From: |
pkamath |
Subject: |
Re: Bison and an one-parse interpreter |
Date: |
Fri, 2 Aug 2002 15:30:16 +0530 |
Hello,
We have been using Flex/Bison for our parsing needs in our project.
We are currently facing a problem which is a generic problem that some of
you might have
come across. Let me explain the problem:-
I have a rule
a: Token1 Token2
{
/*Non recoverable operation*/
}
Now if I have a input set of tokens like
Token1 Token2
things are fine
But if I have a input set of tokens like
Token1 Token2 #
(where # is a forbidden token)
Then first the action code for rule a is executed and then the error
handler for the parser is invoked since
there is a token that is not accepted by the parser.
The problem is once the action code for a is executed then this cannot be
recovered from.
How do we handle this kind of a case?
Is there any way that we can give a rule in bison like
a: Token1 Token2 NOTHINGMORE
which means the tokens must reduce to a *only if* you have
input tokens Token1 Token2 << and nothing after that>>.
This being a basic design problem we would like a fix that would not
require us to
modify our rules much.
Any suggestions/input would go a long way in helping us.
Thanking u for ur valuable time.
With Regards
R.Kamath
Jeppesen Hans Mejdahl <address@hidden> on 08/02/2002 10:38:38 AM
To: "'address@hidden'" <address@hidden>
cc: (bcc: P Raghavendra Kamath/HSSBLR)
Subject: Bison and an one-parse interpreter
Hi there...
I want to build a one-parse interpreter using flex/bison is this possible?
As I see it: simpel expresion and asignments works fine,
BUT: condition and loops :-(
Consider this test "gramma":
if-stmt : IF if-bool THEN true-stmt;
{dont-do=0;};
if-bool : bool:
{ don't-do=1;
$=$1;
};
stmt: id '=' value
{if (!dont-do) setvalue($1,$3) };
This might workbut look like h.... !
And what about a loops ?
Regards Hans M Jeppesen
_______________________________________________
address@hidden http://mail.gnu.org/mailman/listinfo/help-bison