All,
I have written a parser for C that processes
a single statement or declaration at a time.
So after each statement/declaration yyparse
returns.
Originally I used various ad-hoc rules in yylex
to figure out which was the last token of a
statement/declaration and then returned a zero
value as t
At 17:03 + 2005/02/28, Derek M Jones wrote:
>I have written a parser for C that processes
>a single statement or declaration at a time.
>So after each statement/declaration yyparse
>returns.
Bison is clearly not built to handle such applications. The normal thing is
to handle the whole languag
Hans,
>>I have written a parser for C that processes
>>a single statement or declaration at a time.
>>So after each statement/declaration yyparse
>>returns.
>
>Bison is clearly not built to handle such applications. The normal thing is
>to handle the whole language in one go. (How do you handle en
Following is a sample grammar. There is one r/r
conflict.
% cat test.y
%token YYID YYDOT
%%
identifier : hier_id
;
hier_id : simple_id
| hier_id opt_select YYDOT simple_id
;
opt_select :
| opt_select '[' expr ']'
;
simple_id : YYID ;
expr : hier_id
Your grammar is ambigious.
It can be seen if you make the following transformation, factoring out the
null transition of opt_select, and you will see the shift/reduce conflict:
%token YYID YYDOT
%%
identifier : hier_id;
hier_id : simple_id
| hier_id YYDOT simple_id
| hier_id opt_select YYDOT simp
Derek M Jones wrote:
> >>I have written a parser for C that processes
> >>a single statement or declaration at a time.
> >>So after each statement/declaration yyparse
> >>returns.
> >
> >Bison is clearly not built to handle such applications. The normal thing is
> >to handle the whole language in