How can I use the same lexer with multiple parsers?

Terence Parr

Lexers are just objects, so you can attach any parser you want to instances of the same object (just don't have the parsers operate simultaneously--lexers only work on one input stream at a time). The only thing you have to keep in mind is that the vocabularies have to be compatible. In other words, if your parser is looking for INT and ID, but your lexer only generates tokens STRING and STRUCT then you will have a problem. The parser can only apply grammatical structure to a stream of vocabulary symbols it's expecting.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact