Trouble in Error Recovery

"Sidharth" <sidharth.masaldaan@gmail.com>
22 Sep 2005 23:48:31 -0400

          From comp.compilers

Related articles
Trouble in Error Recovery sidharth.masaldaan@gmail.com (Sidharth) (2005-09-22)
Re: Trouble in Error Recovery haberg@math.su.se (2005-09-23)
| List of all articles for this month |
From: "Sidharth" <sidharth.masaldaan@gmail.com>
Newsgroups: comp.compilers
Date: 22 Sep 2005 23:48:31 -0400
Organization: http://groups.google.com
Keywords: errors, yacc
Posted-Date: 22 Sep 2005 23:48:31 EDT

Hi all,
        I'm having trouble in writing error recovery routines. I spent the
last days trying to make error recovery working but I
can't catch one and yyerror is always invoked. I'm using Bison 2.0. n
Flex 2.5.31.


        I have included samples of my grammar, most of the rules are pretty
similar. And i cant switch to any other tool coz of course
requirements. The rebundant Error_Tokens are coz i couldn't think of
any other way to write the err. recovery routines.


Bison Source:-


%token Max_Header_Token DIGITS Error_Token


%%
Max_Header: Max_Header_Token DIGITS {/*action*/}
                  | Error_Token DIGITS { printf("ERROR in header\n"); }
                  | Max_Header_Token Error_Token { printf("ERROR in DIGITS\n");
}
                  ;
%%


Flex Source:-


SPACE [ \t]*
TOKEN "Max-Header"
COLON ":"
HEADER {SPACE}+ {TOKEN}{SPACE}+ {COLON}
DIGITS [0-9]+
Error_Token .+


%%
{HEADER} {return Max_Header_Token;}
{DIGITS} {return DIGITS;}
{Error} {return Error_Token;}
%%


Plz hav a look n tell me if i'm on the right track or hav i screwed up
my basics.
And i'd be grateful if someone could plz explain how exactly to use
yyerrok that'd be a great help 2.


Thanx a lot in advance.


-Sidharth Masaldaan


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.