Hi,
On 24.1.2005, at 18:15, Trans wrote:

> |class Marker < Parser::Token
> |
> |    exclusive false
> |    start { %r{ \< (.*?) \> }mx }
> |    stop { |match| %r{ \< [ ]* (#{esc(match[1])}) (.*?) \. \> }mx }
> |
> |    #... user's optional methods ...
>
> It toke me some time to work this out in itself. And I thought I had
> finally gotten a fairly nice interface here. But to my dismay, I just
> discovered that I can't subclass Marker b/c I loose the definitions of
> the above attributes (ie. exclusive, start, stop). So now I'm back to
> rethinking the whole setup. (Also note that if the user's methods
> redefine #initialize or the other Token methods, it might cause the
> parser that uses it to break --another slight down side and a possible
> use case for RCR #198)
>
> So how does one properly build something like this in a nice neat way?
>

This is the first thought that entered my mind: turn the configuration 
methods into instance methods, move the method calls to #initialize, 
and call super there:

class Marker < Parser::Token
   def initialize
     super
     exclusive false
     start { %r{ \< (.*?) \> }mx }
     stop { |match| %r{ \< [ ]* (#{esc(match[1])}) (.*?) \. \> }mx }
   end
end

class ExclusiveMarker < Marker
   def initialize
     super
     exclusive true
   end
end


Maybe that would work?

--
Ilmari Heikkinen