Managing errors in flex

AaronJSherman@gmail.com (Aaron Sherman)
21 Sep 2004 22:22:05 -0400

          From comp.compilers

Related articles
Managing errors in flex AaronJSherman@gmail.com (2004-09-21)
Re: Managing errors in flex hannah@schlund.de (2004-09-24)
| List of all articles for this month |

From: AaronJSherman@gmail.com (Aaron Sherman)
Newsgroups: comp.compilers
Date: 21 Sep 2004 22:22:05 -0400
Organization: http://groups.google.com
Keywords: lex, question, comment
Posted-Date: 21 Sep 2004 22:22:05 EDT

I have a flex scanner that has the following patterns (among others,
obviously):


    <INITIAL>foo BEGIN(state1);
    <INITIAL>bar BEGIN(state2);
    <state1>token1 yylval.val = yytext; return TOK_TOKEN1;
    <state2>token2 yylval.val = yytext; return TOK_TOKEN2;
    <*><<EOF>> yyterminate();
    <*>.|\n { char s[256];
                                        sprintf(s,"Error at char '%s'\n",yytext);
                                        error(s); }


What I do not understand is why that final rule never executes. I'm
using the "-s" option to flex, and getting "syntax error" instead of
my custom message from above.
[Most likely because <*> isn't a valid start state in any versioon of lex
I'm familiar with. -John]


Post a followup to this message

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