p4-spec icon indicating copy to clipboard operation
p4-spec copied to clipboard

Add scripts to compare spec grammar.mdk file against p4c Bison parser

Open jfingerh opened this issue 3 years ago • 2 comments

jfingerh avatar Dec 08 '22 23:12 jfingerh

With the recent changes to the grammar.mdk file in the p4-spec repo, running these scripts mechanically gets to versions of grammar.mdk and p4parser.ypp from the p4lang/p4c repo that are under 50 "hunks" of output in the diffs.

With a small enhancement that I might still make to the Python program in this PR, I can probably get it to under 30 (by putting every alternative of a grammar rule onto a single line, always).

jfingerh avatar Dec 08 '22 23:12 jfingerh

As of commit 4 on this PR, I am done modifying it now. If you run it with latest p4c and p4-spec repos, there are only 27 "hunks" of difference between the two grammars when trimmed of comments and lines beginning with %.

jfingerh avatar Dec 09 '22 05:12 jfingerh