help-bison
[Top][All Lists]
Advanced

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

Re: Non-greedy wildcard possible? (Long)


From: Magnus Lie Hetland
Subject: Re: Non-greedy wildcard possible? (Long)
Date: Wed, 19 May 2004 19:02:11 +0200
User-agent: Mutt/1.4i

Frank Heckenbach <address@hidden>:
>
[snip]
> - What Magnus wants is indeed the former, that's why I said there is
>   no direct way in flex to do that.
> 
>   Magnus suggested to use standard regex functions to search for
>   `a|bb|ccc', and return the characters before the match as the
>   "plain text" token. This should work, but is not possible in flex,
>   since flex always matches the patterns from the current position
>   (whereas usual regex functions match them anywhere in the string).

I already have a Flex implementation for this that works, actually. It
uses scanner states so that each time a token other than .|\n is
matched, the text up to the current match is returned (with the
appropriate switching of states, calling of yyless(0) and storing of
the current token type).

So that part (returning "non-token" parts of the text as a special
token type) seems to work just fine. But that allows all tokens
everywhere, of course.

-- 
Magnus Lie Hetland              "Wake up!"  - Rage Against The Machine
http://hetland.org              "Shut up!"  - Linkin Park




reply via email to

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