06-21-06 12:25 AM
davids@webmaster.com writes:
> David Shin wrote:
>
> If the delimeter can be literally anything (as opposed to one of a
> special set of characters), then this is extremely difficult to do with
> lex directly. Your best bet is a pre-processor that passes tokens to
> lex. Define a special token that indicates your delimeter and pass all
> delimeters to the lexer as that special token.
>
> A very simple solution would be to always use '' as the delimeter and
> translate all ''s in the input to '\' (unless '' was the delimeter
> chosen by the input as well). Lex can handle this with no problem -- C
> uses constructs much like this.
Well, I don't remember how lex works exactly, but with flex, you could
hack the character -> character-class map (changing temporarily the
character class of the delimiter character). The main problem would
be to make sure that no lookahead occurs too soon.
--
__Pascal Bourguignon__ http://www.informatimago.com/
The rule for today:
Touch my tail, I shred your hand.
New rule tomorrow.
[ Post a follow-up to this message ]
|