Is there way to have some code both in lexer and parser members in combined grammar?

StackOverflow https://stackoverflow.com/questions/20481550

  •  30-08-2022
  •  | 
  •  

Pergunta

I have a utility method which I use in both lexer and parser -generated code in a combined grammar. Other than moving it to an external utility class, is there some way to get rid of copy/paste to members and lexer::members, and have this method emitted both in generated Lexer, and Parser?

I am using Antlr 3... I guess if there's something new that is added in 4 that would also be useful information.

Foi útil?

Solução

No, it is placed in either the parser, or the lexer (both for v3 and v4). If possible, you could, of course, make it static so that it's easily called from both.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top