[code] More lexer nightmares. :(

From: Michael Richter <ttmrichter.att.gmail.com>
Date: Wed, 20 Nov 2013 22:36:25 +0800

In the following samples of code, I'm trying to extract the dot-separated
letters from the rest:

   - :(FOO.BAR)
   - :S(FOO.BAR)
   - :F(BAR.BAZ)
   - :S(FOO.BAR)F(BAR.BAZ)
   - :F(BAR.BAZ)S(FOO.BAR)

That is to say in the resulting syntax-coloured code I should be seeing
FOO.BAR and BAR.BAZ highlighted and nothing else.

I cannot for the life of me get this to work.

I have a lexer pattern "dotted_identifier" which works fine. (It's used
all over the place in my lexer.) If I use this…

':(' * dotted_identifier * ')'

… I get, as expected, :(FOO.BAR) highlighted. If, however, I do anything
outside of this, I get inexplicable behaviour.

#':(' * dotted_identifier * #')'

This will find *any* instance of dotted_identifier and syntax-colour it
along with the two characters before it. *Any* two characters before it,
not just ":(".

':(' * S'SF'^-1 * dotted_identifier * ')'

This will match exactly the same as the first pattern I had above. It will
colour (as expected) :(FOO.BAR), but it will not colour :S(FOO.BAR) or
:F(BAR.BAZ).

I'm really at a loss now to know how to deal with this. Any tips?

-- 
"Perhaps people don't believe this, but throughout all of the discussions
of entering China our focus has really been what's best for the Chinese
people. It's not been about our revenue or profit or whatnot."
--Sergey Brin, demonstrating the emptiness of the "don't be evil" mantra.
-- 
You are subscribed to code.att.foicica.com.
To change subscription settings, send an e-mail to code+help.att.foicica.com.
To unsubscribe, send an e-mail to code+unsubscribe.att.foicica.com.
Received on Wed 20 Nov 2013 - 09:36:25 EST

This archive was generated by hypermail 2.2.0 : Thu 21 Nov 2013 - 06:39:11 EST