From: Trans Date: 2005-01-28T01:31:00+09:00 Subject: Re: Duping a class causes error Good point. Fortunately these classes are all self contained beyond being subclasses of Marker. The reason has to do with some trouble I alsways seem to run into with these types of apps. Basically I have a Parser instance that gets fed Token classes (Markers) which contain class level information on how to recognize the relavent text they will parse. Here a very simple example: require 'yaml' s = "[test]THIS IS A [b]TEST[b.]&tm;[test.]" class XmlTagToken < Parser::Token normal! def self.start( match ) ; %r{ \[ (.*?) \] }mx ; end def self.stop( match ) ; %r{ \[ [ ]* (#{Regexp.escape(match[1])}) (.*?) \. \] }mx ; end end class XmlEntityToken < Parser::Token unit! def self.start( match ) ; %r{ \& (.*?) \; }x ; end end registry = Parser::Registry.new registry.register( XmlTagToken ) registry.register( XmlEntityToken ) cp = Parser.new( registry ) d = cp.parse( s ) y d The I take this further and add instance methods to the tokens to parse sepecialize content. Sometimes that content is "reentrant", that is to say I need to reparse it --like an embedded document. So the problem? How do I talk to my Parser instance from within an instance of a Token? If you have an elgant solution to that I'll give you more than a pat on the back! T.