racket / syntax-color

Other
8 stars 16 forks source link

allow #:command-char argument to scribble lexer #1

Closed AlexKnauth closed 9 years ago

mflatt commented 9 years ago

@robby: Do I remember correctly that DrRacket's syntax colorer will call scribble-lexer multiple times, so that the regular expressions here would be compiled multiple times with the additional argument? If so, I think it makes sense to add a make-scribble-lexerlayer, where scribble-lexer is the result of calling that function with #\@, and so on.

rfindler commented 9 years ago

Yes, I believe so. And I agree that currying is a good approach.

AlexKnauth commented 9 years ago

Ok, I changed it to use the currying approach with make-scribble-lexer and make-scribble-inside-lexer.

mflatt commented 9 years ago

Bumped version, added tests, added docs, and merged. As it turns out, my first test was to use #+ as the character, which broke some of the regexp constructions. I adjusted those constructions.

AlexKnauth commented 9 years ago

Oh, I hadn't thought of that. But shouldn't it use regexp-quote instead to do that?

AlexKnauth commented 9 years ago

Otherwise won't it break for \ and ^ for example? (and probably others I haven't thought of yet)

mflatt commented 9 years ago

I didn't think to try those; \ seems to work and ^ fails. More tests and repairs would be welcome!

mflatt commented 9 years ago

I didn't use regexp-quote because I thought that it would be more complicated than dropping characters into "[...]", but I think I chose badly.