Skip to content

Why in the Java version cpp lexer, the tokens obtained by "getTokens()” do not include whitespace characters? #4573

Answered by kaby76
q1anz1 asked this question in Q&A
Discussion options

You must be logged in to vote

It's probably not a bug, certainly not with Antlr. For whatever reason, the token types are handled differently on purpose between the two grammars. There are advantages for either approach.

In the csharp grammar, whitespace is specified to be have a token created with channel HIDDEN (see code). For the cpp grammar, whitespace is marked as skip, which means that no tokens are created for whitespace (see code). It's hard to say why one grammar was written one way and the other grammar written rthe other way, but the requirements may have been different for the two authors.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@q1anz1
Comment options

Answer selected by q1anz1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants