-
Hello I downloaded the file about parsing C++ syntax from https://github.com/antlr/grammars-v4/tree/master/cpp in Java version, And I found that things went different with the same code:
code for parsing c#:
but in the result: If someone could tell me whether this is my problem or if it's a bug, and also how I can obtain the tokenList with the blank token, that would be great. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 |
Beta Was this translation helpful? Give feedback.
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 asskip
, 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.