<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>full fathom five: Tag grammar</title>
    <link>http://www.michaelstudman.com/fullfathomfive/articles/tag/grammar?tag=grammar</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>the blog of Michael Studman</description>
    <item>
      <title>My Java 5 Antlr grammar</title>
      <description>&lt;p&gt;
After years of toying with Antlr but never actually doing anything useful with it; and after months of merely skimming articles on new Java 5 language features I thought I&amp;#8217;d deepen my understanding of both and update the Antlr Java 1.4 grammar to recognize the new language features.
&lt;/p&gt;
&lt;p&gt;
Suprisingly it only took about a week to polish off, and most of that was spent just cleaning up the grammar and deciding between different ways to structure the output &lt;span class="caps"&gt;AST&lt;/span&gt; (rather than strugling with Antlr tool itself).
&lt;/p&gt;
&lt;p&gt;
For anyone interested, my grammar can be found on &lt;a href="http://www.michaelstudman.com/files/java15/index.html"&gt;my site&lt;/a&gt; and it&amp;#8217;s also hosted at &lt;a href="http://www.antlr.org/grammar/1090713067533/index.html"&gt;antlr.org&lt;/a&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;
As for how well tested it is: I&amp;#8217;ve used it to successfully recognise the entire Java 5 source base, jdigraph&amp;#8217;s source base (an early adopter of generics) and some custom tests I developed. I found the accompanying &lt;span class="caps"&gt;AST&lt;/span&gt; recogniser (as opposed to the token stream recogniser) is a good tool for confirming your tree is structured as you expected it to be. I also visually inspected the &lt;span class="caps"&gt;AST&lt;/span&gt; to ensure its structure was what I expected. An alternative to visual inspection would be great to automatically ensure the grammar stays correct over a lifetime of modifications. I&amp;#8217;d love to hear from anyone who&amp;#8217;s worked on such a tool. A testing framework that used XQuery or XPath querying/assertions on &lt;span class="caps"&gt;DOM&lt;/span&gt;-adapted &lt;span class="caps"&gt;AST&lt;/span&gt; (similar to &lt;span class="caps"&gt;PMD&lt;/span&gt;&amp;#8217;s &lt;span class="caps"&gt;AST&lt;/span&gt; interface) would be my first approach. Comments or experience anyone?
&lt;/p&gt;
&lt;p&gt;
More comments on Antlr and Java 5&amp;#8217;s new language features later.
&lt;/p&gt;</description>
      <pubDate>Sat, 24 Jul 2004 23:00:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:9f39d8d3-0f2a-4a33-af5c-faea0b54dc73</guid>
      <author>Michael Studman</author>
      <link>http://www.michaelstudman.com/fullfathomfive/articles/2004/07/24/my-java-5-antlr-grammar</link>
      <category>Java</category>
      <category>Java/J2EE</category>
      <category>antlr</category>
      <category>grammar</category>
      <category>languages</category>
      <category>codegargle</category>
      <trackback:ping>http://www.michaelstudman.com/fullfathomfive/articles/trackback/45</trackback:ping>
    </item>
    <item>
      <title>I'm a Grammar God</title>
      <description>&lt;p&gt;
According to &lt;a href="http://quizilla.com/users/BaalObsidian/quizzes/How%20grammatically%20sound%20are%20you%3F/"&gt;BaalObsidian&lt;/a&gt; , I&amp;#8217;m a grammar God!
&lt;/p&gt;
&lt;p&gt;
Here&amp;#8217;s their &lt;span class="caps"&gt;HTML&lt;/span&gt; badge to prove it: &lt;br /&gt;
&lt;img src="http://images.quizilla.com/B/BaalObsidian/1080162080_cturesgod3.jpg" alt="Image of Grammar God!" /&gt;&lt;br /&gt;You are a &lt;b&gt;&lt;span class="caps"&gt;GRAMMAR GOD&lt;/span&gt;&lt;/b&gt;!
&lt;br /&gt;&lt;br /&gt;If your mission in life is not already to&lt;br /&gt;preserve the English tongue, it should be.&lt;br /&gt;Congratulations and thank you!
&lt;br /&gt;&lt;br /&gt;&lt;a href="http://quizilla.com/users/BaalObsidian/quizzes/How%20grammatically%20sound%20are%20you%3F/"&gt; How grammatically sound are you?&lt;/a&gt;&lt;br /&gt;brought to you by &lt;a href="http://quizilla.com"&gt;Quizilla&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I think they mean the American English tongue, though.
&lt;/p&gt;</description>
      <pubDate>Sat, 12 Jun 2004 23:00:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:d4221d5d-c939-47a0-abaa-60df74b4fa05</guid>
      <author>Michael Studman</author>
      <link>http://www.michaelstudman.com/fullfathomfive/articles/2004/06/12/im-a-grammar-god</link>
      <category>Miscellaneous</category>
      <category>grammar</category>
      <category>badges</category>
      <category>codegargle</category>
      <category>languages</category>
      <trackback:ping>http://www.michaelstudman.com/fullfathomfive/articles/trackback/55</trackback:ping>
    </item>
  </channel>
</rss>
