From: vikkous Date: 2005-04-24T14:34:35+09:00 Subject: Re: announcing RubyLexer 0.6.0 Florian Gro� wrote: > One simple example would be adding a ".=" assign-result-of-method-call > operator as in "foo = 'bar'; foo .= reverse" At first, I thought, "This guy is dreaming; my code is just too rigid to allow extensions of that kind very easily.". But of course, it wouldn't be too hard for me to special case this one operator in for you if you wanted to... it'd just be a quick hack in RubyLexer#dot... in fact, it could be done in a subclass: [warning: untested code!] class FlorianRubyLexer < RubyLexer def dot(ch) #this is the routine in RubyLexer that handles tokens beginning with '.' if readahead(2)=='.=' KeywordToken.new(@file.read(2),@file.pos-2) else super end end end Not too bad for extensibility, eh? I think things look quite hopeful for your idea, actually.... you do have to know RubyLexer internals to do this kind of thing, but that's true for any library. And you probably want to add operators that create no new ambiguities in the language. This one doesn't create ambiguity, a sign that you've been thinking about this already. Tell me more of the kind of thing you want, and maybe I'll write more of your lexer for you. > See attachment. > � pre.rb � Now that's deviant! Whitespace as a fancy string delimiter... I don't even know if that's what breaks RubyLexer, but that's sick, man, really sick. Ps: what does the code do?