tunnelvisionlabs / antlr4cs

The original, highly-optimized C# Target for ANTLR 4
Other
449 stars 103 forks source link

suppressing warning messages #337

Closed ipetrushevskiy closed 5 years ago

ipetrushevskiy commented 5 years ago

I have a warning message while building my lexer like: 'warning AC0146: non-fragment lexer rule '' can match the empty string' I wanted to suppress it with 'ruleset' but I cant as its code 'AC0146' is not correctly passed somehow (looks like empty from VS error list window for example). Is it any other way to do it? Thanks in advance.

KvanTTT commented 5 years ago

Could you post a part of grammar with such a warning?

ipetrushevskiy commented 5 years ago

lexer grammar TestExample; fragment BlockValue: ~[:{}]*; BLOCK_VALUE: BlockValue;

KvanTTT commented 5 years ago

Just replace star * with plus + to get rid of warnings:

lexer grammar TestExample;
fragment BlockValue: ~[:{}]+;
BLOCK_VALUE: BlockValue;
sharwell commented 5 years ago

@ipetrushevskiy That grammar can match an infinite number of BLOCK_VALUE tokens between any other tokens. The warning needs to be fixed (by ensuring BLOCK_VALUE always matches at least one character) or the grammar is ambiguous.

ipetrushevskiy commented 5 years ago

Thanks for clarifications.