Match two yacc grammars

You wrote the yacc grammar (or some other LALR grammar in the tool of your choice), and you decided that you want to reorganize some pieces for efficiency, clarity, etc. For example, you had:

xs : xs ';' x | xs ';' | x 

You want to make it more obvious that there can be several semicolons, so you rewrite it as:

 semi_plus : semi_plus ';' | ';' xs : xs semi_plus x | x 

OK, so that looks plausible ... but did I do the refactoring right? It would be great if I could pass these declarations to a tool that would tell me if the grammars are equivalent or not. (For now, let's only consider the question of whether we recognize the same languages.)

One knee-jerk reaction is to quote that contextual free grammatical equivalence is unsolvable. In fact, even the problem of determining the correctness of CFG is insoluble . But yacc does not recognize CFG: it recognizes deterministic contextual free grammars, and for them it is known that equivalence is decidable . But has anyone followed any of these decision-making procedures?

+8
complexity-theory parsing
source share

No one has answered this question yet.

See related questions:

14
The practical implications of formal grammar?
eleven
Yacc / Jay Grammar File for JavaScript?
one
biblical / yacc grammar ambiguity
0
Shift / decrease conflict in yacc grammar
0
Who modifies the $$ type in yacc grammar
0
Yacc Grammar Creating Invalid Terminal
0
Yacc Grammar Expressions, Conflicts
0
Conflict in YACC / Bison Grammar
0
Flex and Yacc grammar problem
0
Is a context-free grammar that can be uniquely converted to an LR parsing table?

All Articles