-
|
using antlr4-4.13.3-SNAPSHOT from a few days ago. I've seen my question answered multiple times, but not in the last 6 years, and not correctly for this version. I am using a modified grammars-v4r SvLexer where I've added structured comments as new lexer modes, extending the language to have Annotations and Decorators. I am having trouble finding all of the comments. Since SvParserBaseListener has no methods for anything on the comment channel, I end up missing some comments. I tried using ...Lisenter.enterEveryRule and exitEveryRule and getHiddenTokensTo left and right, but I miss comments, either before the main entry point, or surrounding other channels such as preprocessing, whitespace, or before the EOF. I've been searching for a couple of days and can't find what I'm looking for, including the ANTLR 4 reference. How can I find every complete comment in-between other rules in my listener? Please point me in a good direction. --Moof |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
I just made a loop iterating backwards over the tokens backwards and calling commonTokenStream.get(tokenIndex).getChannel() to find tokens on my comment channel. |
Beta Was this translation helpful? Give feedback.
I just made a loop iterating backwards over the tokens backwards and calling commonTokenStream.get(tokenIndex).getChannel() to find tokens on my comment channel.