help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

input returns characters that should have been consumed??


From: Michael Grigoriev
Subject: input returns characters that should have been consumed??
Date: Fri, 15 Jul 2005 17:29:38 -0400
User-agent: Mutt/1.5.8i

Hi guys,

I am a complete flex newbie, I'm just trying to get a really old program to
compile, so maybe I am missing something completely obvious here.

Any hints would be greatly appreciated.

I am using flex version 2.5.4, and I have #define YY_INPUT(buf, retval, maxlen)
 overwritten to (retval = eval_getinput(buf, maxlen)), which returns the
input one line at a time so that I can parse standard input without
consuming it all, in case that matters.

Now I want to parse something like "define foo X <stuff> X", where X can be
any character. My grammar is as follows:

A       [a-zA-Z_]
B       [a-zA-Z0-9_]

<A>define{WS}+          { BEGIN def; }
<def>{A}{B}*            { definition(yytext); BEGIN A; } 

However inside definition(), when I repeatedly call input() to get the rest
of the line, it returns "define foo bar"! (the parameter for definition is
correctly set to "foo")
Shouldn't "define" and "foo" have been consumed by now?

Is this a bug in flex, or am I doing something wrong?

Thanks in advance.

-- 
Have fun,                               "As the moment elapsed
Michael "mag" Grigoriev                We walked in slowmotion
address@hidden                               Denying the tide
http://www.luminal.org                 We'll find our devotion"

Attachment: pgpACheDEGvYO.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]