help-flex
[Top][All Lists]
Advanced

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

Re: Help with Flex input matching


From: Rubén Béjar
Subject: Re: Help with Flex input matching
Date: Wed, 13 Apr 2005 11:39:56 +0200
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

sean charles wrote:

<rbejar <at> unizar.es> writes:

[...]

According to this, I would expect the next flex program:

    %%
    uva {printf("3");}
    xu {printf("4");}

with this input:
    xuva

to generate this output, because chosing the first rule would match more characters from the input:
    x3

but it is generating this output instead:
    4va

[...]

Ruben,

The output you have is what I would expect anyway. I think you are placing too
much cleverness on flex! The 'xu' rule is satisfied because it is the first
complete match. Let me ask you this; assuming it could match the 'uva' from
those rules, what does it do with the 'x' first? it has to consume the x to find
the start of the match for 'uva' doesn't it, therefore, the 'xu' rule is bound
to match first.

If you gave it the input:

   xuuva

then i think the output might be a little different ie what you were expecting
(I think, going on the top of my head now) so you either have to rethink your
input or your grammar, or both!
Thanks for answering. I was just trying to understand the input match process in flex, so I don't really need to read such problematic strings. It's just that the flex manual doesn't tell too much about the kind of lexical analyzer used, it just *suggests* it is using a DFA in the bibliography section, and the manual neither is very clear, at least to me, in the input matching process description. It seems most people are *assuming* certain behavior based mostly in intuition/experience, and I would have expected the manual to be more comprehensive on that issue. But at least now, I already know what
to expect when matching some complex inputs.

        Ruben Bejar







reply via email to

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