Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How can I use the same lexer with multiple parsers?

lexer parsers
0
Posted

How can I use the same lexer with multiple parsers?

0

Location: http://www.jguru.com/faq/view.jsp?EID=93710 Created: Jul 2, 2000 Modified: 2000-07-02 13:13:29.777 Author: Terence Parr (http://www.jguru.com/guru/viewbio.jsp?EID=1) Question originally posed by Terence Parr PREMIUM (http://www.jguru.com/guru/viewbio.jsp?EID=1 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.

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123