Forcing multiple parse stacks to 'reduce'

2005-02-28 Thread Derek M Jones
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

Re: Forcing multiple parse stacks to 'reduce'

2005-02-28 Thread Hans Aberg
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

Re: Forcing multiple parse stacks to 'reduce'

2005-02-28 Thread Derek M Jones
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

Identifying rule responsible for lookahead

2005-02-28 Thread Soumitra Kumar
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

Re: Identifying rule responsible for lookahead

2005-02-28 Thread Henrik Sorensen
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

Re: Forcing multiple parse stacks to 'reduce'

2005-02-28 Thread Frank Heckenbach
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