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
  •  | 
  •  

문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top