<?xml version="1.0"?>
<rss version="2.0">
<channel>
  <title>Weiqi Gao&#039;s Observations - antlr tag</title>
  <link>http://www.weiqigao.com/blog/tags/antlr/</link>
  <description>Sharing My Experience...</description>
  <language>en</language>
  <copyright>Weiqi Gao</copyright>
  <lastBuildDate>Fri, 11 May 2012 12:48:36 GMT</lastBuildDate>
  <generator>Pebble (http://pebble.sourceforge.net)</generator>
  <docs>http://backend.userland.com/rss</docs>
  
  <image>
    <url>http://pebble.sourceforge.net/common/images/powered-by-pebble.gif</url>
    <title>Weiqi Gao&#039;s Observations</title>
    <link>http://www.weiqigao.com/blog/</link>
  </image>
  
  
  <item>
    <title>Java News Brief (JNB): ANTLR 3.0</title>
    <link>http://www.weiqigao.com/blog/2008/06/04/java_news_brief_jnb_antlr_3_0.html</link>
    
      
        <description>
          &lt;p&gt;This month&#039;s &lt;a href= &#034;http://www.ociweb.com/&#034; &gt;OCI&lt;/a&gt; &lt;a href= &#034;http://www.weiqigao.com/blog/jnb/&#034; &gt;Java News Brief (JNB)&lt;/a&gt; article is out.  In this article, &lt;a href= &#034;http://www.ociweb.com/mark/&#034; &gt;Mark Volkmann&lt;/a&gt; continues his effort in &lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html&#034; &gt;getting you to be proficient&lt;/a&gt; with &lt;a href= &#034;http://antlr.org/&#034; &gt;ANTLR 3.0&lt;/a&gt;. (Actually, you need ANTLR 3.1b1 to compile the grammars in the article.)&lt;/p&gt;

&lt;blockquote&gt;&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html&#034; &gt;Mark Volkmann&lt;/a&gt;: &lt;h1 style=&#034;text-align:center&#034;&gt;ANTLR 3.0&lt;/h1&gt;
    &lt;p style=&#034;text-align:center&#034;&gt; by&lt;br&gt;
      R. Mark Volkmann, Partner/Software Engineer &lt;br&gt;Object Computing, Inc. (OCI)&lt;/p&gt;


&lt;h3&gt;Table of Contents&lt;/h3&gt;
    &lt;table&gt;
      &lt;tbody&gt;&lt;tr&gt;

        &lt;td colspan=&#034;1&#034; rowspan=&#034;1&#034; style=&#034;vertical-align: top;&#034;&gt;
          &lt;ul&gt;
            &lt;li&gt;Part I - Overview
              &lt;ul&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#Introduction&#034; &gt;Introduction To ANTLR&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#Overview&#034; &gt;ANTLR Overview&lt;/a&gt;
&lt;/li&gt;

                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#UseCases&#034; &gt;Use Cases&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#OtherApproaches&#034; &gt;Other DSL Approaches&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#Definitions&#034; &gt;Definitions&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;

&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#GeneralSteps&#034; &gt;General Steps&lt;/a&gt;
&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;Part II - Jumping In
              &lt;ul&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#ExampleDescription&#034; &gt;Example Description&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;

&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#ImportantClasses&#034; &gt;Important Classes&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#GrammarSyntax&#034; &gt;Grammar Syntax&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#GrammarOptions&#034; &gt;Grammar Options&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#GrammarActions&#034; &gt;Grammar Actions&lt;/a&gt;

&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;Part III - Lexers
              &lt;ul&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#LexerRules&#034; &gt;Lexer Rules&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#WhitespaceAndComments&#034; &gt;Whitespace and Comments&lt;/a&gt;

&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#OurLexerGrammar&#034; &gt;Our Lexer Grammar&lt;/a&gt;
&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;/td&gt;
        &lt;td colspan=&#034;1&#034; rowspan=&#034;1&#034; style=&#034;vertical-align: top;&#034;&gt;
          &lt;ul&gt;

            &lt;li&gt;Part IV - Parsers
              &lt;ul&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#TokenSpecifications&#034; &gt;Token Specifications&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#RuleSyntax&#034; &gt;Rule Syntax&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#CreatingASTs&#034; &gt;Creating ASTs&lt;/a&gt;

&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#RuleArgsAndReturnValues&#034; &gt;Rule Arguments and Return Values&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#OurParserGrammar&#034; &gt;Our Parser Grammar&lt;/a&gt;
&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;Part V - Tree Parsers
              &lt;ul&gt;

                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#RuleActions&#034; &gt;Rule Actions&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#AttributeScopes&#034; &gt;Attribute Scopes&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#OurTreeGrammar&#034; &gt;Our Tree Grammar&lt;/a&gt;
&lt;/li&gt;
              &lt;/ul&gt;

            &lt;/li&gt;
            &lt;li&gt;Part VI - &lt;a href=&#034;http://ociweb.com/jnb/jnbJun2008.html#ANTLRWorks&#034; &gt;ANTLRWorks&lt;/a&gt;
&lt;/li&gt;
            &lt;li&gt;Part VII - Putting It All Together
              &lt;ul&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#UsingGeneratedClasses&#034; &gt;Using Generated Classes&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;

&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#AntTips&#034; &gt;Ant Tips&lt;/a&gt;
&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
            &lt;li&gt;Part VIII - Wrap Up
              &lt;ul&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#HiddenTokens&#034; &gt;Hidden Tokens&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;

&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#AdvancedTopics&#034; &gt;Advanced Topics&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#ProjectsUsing&#034; &gt;Projects Using ANLTR&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#Books&#034; &gt;Books&lt;/a&gt;
&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#Summary&#034; &gt;Summary&lt;/a&gt;

&lt;/li&gt;
                &lt;li&gt;
&lt;a href= &#034;http://ociweb.com/jnb/jnbJun2008.html#References&#034; &gt;References&lt;/a&gt;
&lt;/li&gt;
              &lt;/ul&gt;
            &lt;/li&gt;
          &lt;/ul&gt;
        &lt;/td&gt;
      &lt;/tr&gt;&lt;/tbody&gt;
    &lt;/table&gt;
&lt;/blockquote&gt;

&lt;p&gt;As always with JNB articles, this one is intended for you to follow along.  So download ANTLR 3.1b1, fire up your bash and vim, and learn some language recognition tricks.&lt;/p&gt;

&lt;p&gt;On a related note, Martin Fowler recently &lt;a href= &#034;http://martinfowler.com/bliki/ParserFear.html&#034; &gt;blogged about a phenomenon he calls Parser Fear&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;a href= &#034;http://martinfowler.com/bliki/ParserFear.html&#034; &gt;Martin Fowler&lt;/a&gt;: I talk quite a bit with people about &lt;a href= &#034;http://martinfowler.com/bliki/DomainSpecificLanguage.html&#034; &gt;DomainSpecificLanguages&lt;/a&gt; these days and a common reaction I get to external DSLs is that it&#039;s hard to write a parser.
&lt;/blockquote&gt;

&lt;p&gt;He went on to say that creating an external DSL with ANTLR is just as fast as using XML files, where supposedly you get the parser for free.&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2008/06/04/java_news_brief_jnb_antlr_3_0.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2008/06/04/java_news_brief_jnb_antlr_3_0.html</guid>
    <pubDate>Wed, 04 Jun 2008 15:33:29 GMT</pubDate>
  </item>
  
  <item>
    <title>Mark Volkmann: An Introduction To ANTLR v3</title>
    <link>http://www.weiqigao.com/blog/2008/02/18/mark_volkmann_an_introduction_to_antlr_v3.html</link>
    
      
        <description>
          &lt;p&gt;Last Friday, &lt;a href= &#034;http://www.ociweb.com/mark/&#034; &gt;Mark Volkmann&lt;/a&gt; presented a tutorial on &lt;a href= &#034;http://antlr.org/&#034; &gt;ANTLR&lt;/a&gt; v3 at the OCI internal Java lunch.  Since Mark has posted his &lt;a href= &#034;http://www.ociweb.com/mark/programming/ANTLR3.html&#034; &gt;presentation slides&lt;/a&gt; out on the internet, I did not take my usual amount of notes.&lt;/p&gt;

&lt;p&gt;For me, ANTLR has been something that I&#039;m aware of for a long time.  I may have encountered it before it became ANTLR (PCCTS) when it was C++ based.  However, its lack of applicability in everyday programming and the terseness of the documentation meant that I never get to know it well enough to actually use it in production code.  The situation changed last year when the Pragmatic Bookshelf published the &lt;a href= &#034;http://www.pragprog.com/titles/tpantlr&#034; &gt;The Definitive ANTLR Reference&lt;/a&gt; book.&lt;/p&gt;

&lt;p&gt;I have been staring at my copy of the book for a few months waiting for the time when I would have a big chunk of time to start reading and experimenting with it.  Mark&#039;s talk gave me enough of a push to start my experimentation with ANTLR v3.  Hopefully, this time I can sustain my energy and finish the book.&lt;/p&gt;

&lt;p&gt;And one particularly good thing about Mark&#039;s talk is that its accompanied by a &lt;a href= &#034;http://www.ociweb.com/mark/programming/ANTLR3/Math.zip&#034; &gt;couple&lt;/a&gt; of &lt;a href= &#034;http://www.ociweb.com/mark/programming/ANTLR3/MathWithStringTemplate.zip&#034; &gt;examples&lt;/a&gt; that I can play with.  Here&#039;s what the example does:&lt;/p&gt;

&lt;pre style=&#034;margin-left:3em&#034;&gt;[weiqi@gao Math]$ &lt;b&gt;java -jar build/math.jar&lt;/b&gt; 
math&gt; &lt;b&gt;f(x) = x^2 - 3x + 2&lt;/b&gt;
math&gt; &lt;b&gt;print f()&lt;/b&gt;
f(x) = x^2 - 3x + 2
math&gt; &lt;b&gt;print f&#039;()&lt;/b&gt;
f&#039;(x) = 2x - 3
math&gt; &lt;b&gt;print f(3)&lt;/b&gt;
2.0
math&gt; &lt;b&gt;help&lt;/b&gt;
In the help below
* fn stands for function name
* n stands for a number
* v stands for variable

To define
* a variable: v = n
* a function from a polynomial: fn(v) = polynomial-terms
  (for example, f(x) = 3x^2 - 4x + 1)
* a function from adding or subtracting two others: fn3 = fn1 +|-ghg fn2
  (for example, h = f + g)

To print
* a literal string: print &#034;text&#034;
* a number: print n
* the evaluation of a function: print fn(n | v)
* the defintion of a function: print fn()
* the derivative of a function: print fn&#039;()
* multiple items on the same line: print i1 i2 ... in

To list
* variables defined: list variables
* functions defined: list functions

To get help: help or ?

To exit: exit or quit
&lt;/pre&gt;

&lt;p&gt;If you&#039;ve been trying to get to know a little bit about ANTLR but never have the right incentive or courage to open the book, give Mark&#039;s presentation material a try.  And if you are in the St. Louis area, Mark will be giving the same presentation at the &lt;a href= &#034;http://www.nofluffjuststuff.com/conference/st_louis/2008/03/index.html&#034; &gt;NFJS conference&lt;/a&gt; in March and the &lt;a href= &#034;http://www.ociweb.com/javasig/&#034; &gt;St. Louis Java Users Group&lt;/a&gt; in June.&lt;/p&gt;

&lt;p&gt;Come!&lt;/p&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2008/02/18/mark_volkmann_an_introduction_to_antlr_v3.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2008/02/18/mark_volkmann_an_introduction_to_antlr_v3.html</guid>
    <pubDate>Tue, 19 Feb 2008 02:43:09 GMT</pubDate>
  </item>
  
  <item>
    <title>ANTLR 3.0 Is Released</title>
    <link>http://www.weiqigao.com/blog/2007/05/17/antlr_3_0_is_released.html</link>
    
      
        <description>
          &lt;ul&gt;
&lt;li&gt;&lt;a href= &#034;http://www.artima.com/lejava/articles/antlr_3.html&#034; &gt;Terence Parr Introduces ANTLR 3.0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href= &#034;http://www.antlr.org/&#034; &gt;ANTLR Parser Generator&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href= &#034;http://www.pragmaticprogrammer.com/titles/tpantlr/index.html&#034; &gt;The Definitive ANTLR Reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
        </description>
      
      
    
    
    
    <comments>http://www.weiqigao.com/blog/2007/05/17/antlr_3_0_is_released.html#comments</comments>
    <guid isPermaLink="true">http://www.weiqigao.com/blog/2007/05/17/antlr_3_0_is_released.html</guid>
    <pubDate>Fri, 18 May 2007 02:45:42 GMT</pubDate>
  </item>
  
  </channel>
</rss>

