[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

lexer customization

Dear sablecc users,
I have a problem with a specific specialization of my sablecc generated lexer (and, eventually, also the parser). My project involves collecting scattered regular expressions from a fairly large repository of XML files. The regexps have to be preprocessed and joined to regexp disjunctions that will eventually be compiled using the sablecc parser generated from my regexp grammar.
I use an XML parser to get at the regexps. Preprocessing involves collecting references used in the regexps. To detect the references in regexps, I would like to use my lexer.
The problem starts here: the generated lexer takes a PushbackReader as a constructor argument, so I would have to create a new lexer object for each new regexp though I actually need only a single lexer for parsing each new regexp.
How can I customize the lexer by adding something like a setReader() method to a lexer subclass?
Do I have to copy&paste the code in Lexer(PushbackReader in) to such a setReader() method?
Thanks a lot for help and suggestions,