For Programmers: Free Programming Magazines  


Home > Archive > Compilers > September 2004 > Managing errors in flex









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Managing errors in flex
Aaron Sherman

2004-09-22, 3:59 am

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]
Hannah Schroeter

2004-09-24, 4:00 am

Hello!

Aaron Sherman <AaronJSherman@gmail.com> wrote:
>[...]


>[Most likely because <*> isn't a valid start state in any versioon of lex
>I'm familiar with. -John]


The flex manpage says:

<*>r An `r' in any start condition, even an exclusive one.

Kind regards,

Hannah.
[Oh, look, you're right. I've had a lot of trouble with flex start
states. I think there are lurking bugs. -John]
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com