{"id":2666,"date":"2020-05-06T08:47:07","date_gmt":"2020-05-06T12:47:07","guid":{"rendered":"http:\/\/codinggorilla.com\/?p=2666"},"modified":"2020-05-06T15:43:23","modified_gmt":"2020-05-06T19:43:23","slug":"the-next-step","status":"publish","type":"post","link":"http:\/\/165.227.223.229\/index.php\/2020\/05\/06\/the-next-step\/","title":{"rendered":"The next step"},"content":{"rendered":"\n<p>What is the next step in Antlrvsix to help improve a grammar? To answer that, I decided to go back and take a look at where this all began, with the <a href=\"http:\/\/codinggorilla.com\/?p=2284\" class=\"ek-link\">comparison of the Java grammars<\/a> in Antlr.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/antlr\/grammars-v4\/tree\/master\/java\/java9\" class=\"ek-link\">Java9<\/a> is derived from version 9 of the <a href=\"https:\/\/docs.oracle.com\/javase\/specs\/jls\/se14\/html\/index.html\" class=\"ek-link\">Java spec<\/a>. <a href=\"https:\/\/github.com\/antlr\/grammars-v4\/tree\/master\/java\/java\" class=\"ek-link\">Parr&#8217;s Java <\/a>is derived from an unknown, earlier version of the spec, but it is much faster in parsing that the other grammar.<\/p>\n\n\n\n<p>How can one compare these grammars? A line-by-line diff of the files could be done, but it is a terrible way to compare the grammars because they are very different: one is a partitioned grammar, the other a combined grammar; the formatting is different; the rules in each grammar are ordered differently; and, the rules differ considerably between the grammars. In order to compare the grammars, a much smarter diff is needed.<\/p>\n\n\n\n<p>What I&#8217;m planning is to do a rule-by-rule comparison, working with rules in a DFS order from the start rule. I&#8217;ll need to know how the rules differ and why. Then, using Antlrvsix, apply a transformation to make the rules the same, and continue the diff with the next rule in the DFS ordering.<\/p>\n\n\n\n<p>So, I first applied a DFS reorder of the grammars using the Antlrvsix extension, then a reformat (<a href=\"https:\/\/github.com\/kaby76\/AntlrVSIX\/issues\/37\" class=\"ek-link\">it turns out Codebuff has some bugs<\/a>). Starting with the start rules, <em>compilationUnit<\/em>, the difference has already started: Parr decided to unfold <em>ordinaryCompilation<\/em> and remove the rule.<\/p>\n\n\n\n<p>I could edit the grammar manually for the rule, but I decided to save time and implement the fold transformation right now. And, in order to make this reproducible, I want Antlrvsix to take a sequence of transformations from a file and apply them.<\/p>\n\n\n\n<p>&#8211;Ken<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is the next step in Antlrvsix to help improve a grammar? To answer that, I decided to go back and take a look at where this all began, with the comparison of the Java grammars in Antlr. Java9 is derived from version 9 of the Java spec. Parr&#8217;s Java is derived from an unknown, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/165.227.223.229\/index.php\/2020\/05\/06\/the-next-step\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;The next step&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/2666"}],"collection":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/comments?post=2666"}],"version-history":[{"count":0,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/posts\/2666\/revisions"}],"wp:attachment":[{"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/media?parent=2666"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/categories?post=2666"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/165.227.223.229\/index.php\/wp-json\/wp\/v2\/tags?post=2666"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}