Open kaby76 opened 1 year ago
There appear to be some problems in the grammars for unused lexer symbols. For example, in z/, SET_MINUS is missing in expression; in yara/, QM/'?' and SLASH/'/' are missing in the grammar; in xpath/xpath2/, BANG/'!' is missing.
Similar to the analysis for parser rules, one can perform an analysis of unused lexer rules. However, the analysis needs to remove from consideration grammars that use a
.
-operator in a parser rule (not checked), and whether the lexer rule has lexer commands, e.g.,WS: [ ]+ -> skip;
, which never appear on the RHS of a lexer or parser rule. Also, Antlr4 has "implicit" references to lexer rules for string literals, e.g.,PLUS: '+'; expr : expr '+' expr | ... ;
. So, the lexer symbols have to be folded into the parser rule. Finally, the lexer rule can be referenced in either lexer or parser rules. So, the analysis is slower because there is more to check.This analysis uses the following script. The results should be taken as possible problems. Further analysis of each symbol should then be performed.
Output