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 do I use a non-ANTLR-generated (C++) lexer into an ANTLR-generated parser?

antlr-generated lexer parser
0
Posted

How do I use a non-ANTLR-generated (C++) lexer into an ANTLR-generated parser?

0

Location: http://www.jguru.com/faq/view.jsp?EID=88710 Created: Jun 28, 2000 Modified: 2000-06-28 22:59:45.872 Author: Ric Klaren (http://www.jguru.com/guru/viewbio.jsp?EID=11059) Question originally posed by Robert Hodge (http://www.jguru.com/guru/viewbio.jsp?EID=69371 Subclass your scanner from antlr::TokenStream and make it adhere to the interface defined by TokenStream. Basically this comes down to defining a nextToken function in your scanner class. I use (+/-) the following to link a Cocktail rex scanner to antlr: #include class Scanner : public antlr::TokenStream { // implement a nextToken function.. antlr::RefToken nextToken( void ) { int tok; char yytext[MAX_STRING]; // do scanner magic… … // set tok and yytext..

What is your question?

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

Experts123