Open kaby76 opened 1 year ago
The following are the start symbols of the preprocessor grammars that I authored. Since the lexer processes both the source code and compiler directives at once, there is only one EOF
token which appears in the start symbol(s) of the parser grammar and is omitted in the preprocessor parser grammar.
GLSLPreParser.g4:translation_unit
SystemVerilogPreParser.g4:source_text
VerilogPreParser.g4:source_text
As I thought I mentioned, the symbols in this list may be errors, or may not. The Verilog grammars are okay. We'll need to get trgen to be up to snuff for testing of it.
Each one of these symbols in this list is going to tell an interesting story. Let's look at a few.
empty_statement
rule was added 6 years ago to the grammar, having an applied occurrence in sql_clause. Then, someone made a massive set of changes that removed the reference (the sql_clause
rule was completely nuked), and left the unused rule. The rule should have been removed in the grammar clean up. But, Trash wasn't very far along three years ago.expression
. The Spec for Z and the alts listed in the grammar are similar until just after the alt with the "powerset" operator.magicConstant
is used, magicMethod
is not. And, neither of these are in the grammar for the PHP spec. This code came about 8 years ago, apparently for version 5.6 of PHP, which is probably before PHP even had a spec and a grammar contained in it. Perhaps it's time to get this grammar in synch with the spec.
I wrote a little Trash script to see what I would find in grammars-v4 for unreferenced parser rule symbols, where there is a parser rule defined, but the LHS symbol of the rule is never reference anywhere in the grammar files. I was surprised to find a lot of parser rules that aren't used.
Perhaps the references to these rules were refactored out of the grammar purposefully. For example, to eliminate indirectly left recursion, unfolding is usually performed. But, afterward, unused rules should have been then been deleted.
Unused rules likely indicate an error in the grammar.
Here is the script and output:
Find unused parser symbols
Unused symbols in grammars-v4