[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CSharp backend



And just to prove my point here's the XML generating code:

http://www.mare.ee/indrek/sablecc/xml4sablecc-0.1a.tar.gz

As example I've attached a sablecc grammar file, generated xml,
an example xslt template file and output from xslt processing.

Isn't this great. Not to mention that almost every programming
language out there supports xml. Python, perl, etc.
All nice scripting languages now at our disposal.

Regards,
Indrek
Package expression;

Helpers

    digit = ['0' .. '9'];
    tab = 9;
    cr = 13;
    lf = 10;
    eol = cr lf | cr | lf;

    blank = (' ' | tab | eol)+;

Tokens
    l_par = '(';
    r_par = ')';
    plus = '+';
    minus = '-';
    mult = '*';
    div = '/';
    semi = ';';

    blank = blank;
    number = digit+;

    one = 'one';
    two = 'two';
    three = 'three';

    random = 'random_digit';


Ignored Tokens

    blank;

Productions

    grammar           = exp_list                    {-> New grammar ([exp_list.exp])}
                      ;

    exp_list          {-> exp*} =
                        {list}    exp_list separator exp {-> [exp_list.exp exp.exp] }
                      | {single}  exp               {-> [exp.exp] }
                      ;

    exp               {-> exp} =  
                        {plus}    exp plus factor   {-> New exp.plus (exp.exp, factor.exp) }
                      | {minus}   exp minus factor  {-> New exp.minus (exp.exp, factor.exp) }
                      | {factor}  factor            {-> factor.exp }
                      ;

    factor            {-> exp} =
                        {mult}    factor mult term  {-> New exp.mult (factor.exp, term.exp) }
                      | {div}     factor div term   {-> New exp.div (factor.exp, term.exp) }
                      | {term}    term              {-> term.exp }
                      ;

    term              {-> exp} =
                        {number}  number            {-> New exp.number(number) }
                      | {exp}     l_par exp r_par   {-> exp.exp }
                      | {textual} textual+          {-> New exp.textual ([textual]) }
                      | {random_x2} random_x2       {-> New exp.random_x2 (random_x2.ran1, random_x2.ran2) }
                      ;

    textual           =
                        {t1}      one
                      | {t2}      two
                      | {t3}      three
                      ;

    random_x2         {-> [ran1]:random [ran2]:random} =
                        [ran1]:random [ran2]:random {-> ran1 ran2 }
                      ;

    separator {-> }  =
                        {semicolon} semi {-> }
                      ;
                      

Abstract Syntax Tree

    grammar           = exp*
                      ;

    exp               =
                        {plus}    [l]:exp  [r]:exp |
                        {minus}   [l]:exp  [r]:exp |
                        {div}     [l]:exp  [r]:exp |
                        {mult}    [l]:exp  [r]:exp |
                        {textual} textual* |
                        {random_x2} [r1]:random [r2]:random |
                        {number}  number
                      ;

    textual            =
                        {t1}      one
                      | {t2}      two
                      | {t3}      three
                      ;

<?xml version="1.0"?>
<parser package="expression">
  <tokens>
    <fixed name="l_par" ename="TLPar" index="0" value="("/>
    <fixed name="r_par" ename="TRPar" index="1" value=")"/>
    <fixed name="plus" ename="TPlus" index="2" value="+"/>
    <fixed name="minus" ename="TMinus" index="3" value="-"/>
    <fixed name="mult" ename="TMult" index="4" value="*"/>
    <fixed name="div" ename="TDiv" index="5" value="/"/>
    <fixed name="semi" ename="TSemi" index="6" value=";"/>
    <variable name="blank" ename="TBlank" index="-1"/>
    <variable name="number" ename="TNumber" index="7"/>
    <fixed name="one" ename="TOne" index="8" value="one"/>
    <fixed name="two" ename="TTwo" index="9" value="two"/>
    <fixed name="three" ename="TThree" index="10" value="three"/>
    <fixed name="random" ename="TRandom" index="11" value="random_digit"/>
    <eof index="12"/>
  </tokens>
  <lexerdata>
    <state name="INITIAL" id="0"/>
    <accept>
      <state>
        <i>-1</i><i>7</i><i>7</i><i>7</i><i>7</i><i>0</i><i>1</i><i>4</i><i>2</i><i>3</i><i>5</i><i>8</i><i>6</i><i>-1</i><i>-1</i><i>-1</i><i>7</i><i>-1</i><i>-1</i><i>-1</i><i>-1</i><i>9</i><i>-1</i><i>-1</i><i>10</i><i>-1</i><i>-1</i><i>-1</i><i>11</i><i>-1</i><i>-1</i><i>-1</i><i>-1</i><i>-1</i><i>-1</i><i>12</i>
      </state>
    </accept>
    <goto_table>
      <state>
        <row>
          <goto low="9" high="9" state="1"/>
          <goto low="10" high="10" state="2"/>
          <goto low="13" high="13" state="3"/>
          <goto low="32" high="32" state="4"/>
          <goto low="40" high="40" state="5"/>
          <goto low="41" high="41" state="6"/>
          <goto low="42" high="42" state="7"/>
          <goto low="43" high="43" state="8"/>
          <goto low="45" high="45" state="9"/>
          <goto low="47" high="47" state="10"/>
          <goto low="48" high="57" state="11"/>
          <goto low="59" high="59" state="12"/>
          <goto low="111" high="111" state="13"/>
          <goto low="114" high="114" state="14"/>
          <goto low="116" high="116" state="15"/>
        </row>
        <row>
          <goto low="9" high="32" state="-2"/>
        </row>
        <row>
          <goto low="9" high="32" state="-2"/>
        </row>
        <row>
          <goto low="9" high="9" state="1"/>
          <goto low="10" high="10" state="16"/>
          <goto low="13" high="32" state="-2"/>
        </row>
        <row>
          <goto low="9" high="32" state="-2"/>
        </row>
        <row>
        </row>
        <row>
        </row>
        <row>
        </row>
        <row>
        </row>
        <row>
        </row>
        <row>
        </row>
        <row>
          <goto low="48" high="57" state="11"/>
        </row>
        <row>
        </row>
        <row>
          <goto low="110" high="110" state="17"/>
        </row>
        <row>
          <goto low="97" high="97" state="18"/>
        </row>
        <row>
          <goto low="104" high="104" state="19"/>
          <goto low="119" high="119" state="20"/>
        </row>
        <row>
          <goto low="9" high="32" state="-2"/>
        </row>
        <row>
          <goto low="101" high="101" state="21"/>
        </row>
        <row>
          <goto low="110" high="110" state="22"/>
        </row>
        <row>
          <goto low="114" high="114" state="23"/>
        </row>
        <row>
          <goto low="111" high="111" state="24"/>
        </row>
        <row>
        </row>
        <row>
          <goto low="100" high="100" state="25"/>
        </row>
        <row>
          <goto low="101" high="101" state="26"/>
        </row>
        <row>
        </row>
        <row>
          <goto low="111" high="111" state="27"/>
        </row>
        <row>
          <goto low="101" high="101" state="28"/>
        </row>
        <row>
          <goto low="109" high="109" state="29"/>
        </row>
        <row>
        </row>
        <row>
          <goto low="95" high="95" state="30"/>
        </row>
        <row>
          <goto low="100" high="100" state="31"/>
        </row>
        <row>
          <goto low="105" high="105" state="32"/>
        </row>
        <row>
          <goto low="103" high="103" state="33"/>
        </row>
        <row>
          <goto low="105" high="105" state="34"/>
        </row>
        <row>
          <goto low="116" high="116" state="35"/>
        </row>
        <row>
        </row>
      </state>
    </goto_table>
  </lexerdata>
  <production name="grammar" ename="PGrammar">
    <alt name="grammar" ename="AGrammar">
      <elem name="exp" ename="Exp" type="exp" etype="PExp" modifier="*" is_token="false" is_list="true"/>
    </alt>
  </production>
  <production name="exp" ename="PExp">
    <alt name="plus" ename="APlusExp">
      <elem name="l" ename="L" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
      <elem name="r" ename="R" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
    </alt>
    <alt name="minus" ename="AMinusExp">
      <elem name="l" ename="L" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
      <elem name="r" ename="R" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
    </alt>
    <alt name="div" ename="ADivExp">
      <elem name="l" ename="L" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
      <elem name="r" ename="R" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
    </alt>
    <alt name="mult" ename="AMultExp">
      <elem name="l" ename="L" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
      <elem name="r" ename="R" type="exp" etype="PExp" modifier="" is_token="false" is_list="false"/>
    </alt>
    <alt name="textual" ename="ATextualExp">
      <elem name="textual" ename="Textual" type="textual" etype="PTextual" modifier="*" is_token="false" is_list="true"/>
    </alt>
    <alt name="random_x2" ename="ARandomX2Exp">
      <elem name="r1" ename="R1" type="random" etype="TRandom" modifier="" is_token="true" is_list="false"/>
      <elem name="r2" ename="R2" type="random" etype="TRandom" modifier="" is_token="true" is_list="false"/>
    </alt>
    <alt name="number" ename="ANumberExp">
      <elem name="number" ename="Number" type="number" etype="TNumber" modifier="" is_token="true" is_list="false"/>
    </alt>
  </production>
  <production name="textual" ename="PTextual">
    <alt name="t1" ename="AT1Textual">
      <elem name="one" ename="One" type="one" etype="TOne" modifier="" is_token="true" is_list="false"/>
    </alt>
    <alt name="t2" ename="AT2Textual">
      <elem name="two" ename="Two" type="two" etype="TTwo" modifier="" is_token="true" is_list="false"/>
    </alt>
    <alt name="t3" ename="AT3Textual">
      <elem name="three" ename="Three" type="three" etype="TThree" modifier="" is_token="true" is_list="false"/>
    </alt>
  </production>
  <rule ename="AGrammar" index="0" leftside="0">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="MAKELIST" result="listNode3" etype="PExp"/>
    <action cmd="FETCHLIST" result="listNode2" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="ADDLIST" tolist="listNode3" list="listNode2"/>
    <action cmd="MAKENODE" result="pgrammarNode1" etype="AGrammar">
      <arg>listNode3</arg>
    </action>
    <action cmd="RETURNNODE" etype="PGrammar" node="pgrammarNode1"/>
  </rule>
  <rule ename="AListExpList" index="1" leftside="1">
    <action cmd="POP" result="nodeArrayList3"/>
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="MAKELIST" result="listNode3" etype="PExp"/>
    <action cmd="FETCHLIST" result="listNode1" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode2" index="0" etype="PExp" from="nodeArrayList3"/>
    <action cmd="ADDLIST" tolist="listNode3" list="listNode1"/>
    <action cmd="ADDNODE" etype="PExp" tolist="listNode3" node="pexpNode2"/>
    <action cmd="RETURNLIST" list="listNode3"/>
  </rule>
  <rule ename="ASingleExpList" index="2" leftside="1">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="MAKELIST" result="listNode2" etype="PExp"/>
    <action cmd="FETCHNODE" result="pexpNode1" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="ADDNODE" etype="PExp" tolist="listNode2" node="pexpNode1"/>
    <action cmd="RETURNLIST" list="listNode2"/>
  </rule>
  <rule ename="APlusExp" index="3" leftside="2">
    <action cmd="POP" result="nodeArrayList3"/>
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode2" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode3" index="0" etype="PExp" from="nodeArrayList3"/>
    <action cmd="MAKENODE" result="pexpNode1" etype="APlusExp">
      <arg>pexpNode2</arg>
      <arg>pexpNode3</arg>
    </action>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="AMinusExp" index="4" leftside="2">
    <action cmd="POP" result="nodeArrayList3"/>
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode2" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode3" index="0" etype="PExp" from="nodeArrayList3"/>
    <action cmd="MAKENODE" result="pexpNode1" etype="AMinusExp">
      <arg>pexpNode2</arg>
      <arg>pexpNode3</arg>
    </action>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="AFactorExp" index="5" leftside="2">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode1" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="AMultFactor" index="6" leftside="3">
    <action cmd="POP" result="nodeArrayList3"/>
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode2" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode3" index="0" etype="PExp" from="nodeArrayList3"/>
    <action cmd="MAKENODE" result="pexpNode1" etype="AMultExp">
      <arg>pexpNode2</arg>
      <arg>pexpNode3</arg>
    </action>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="ADivFactor" index="7" leftside="3">
    <action cmd="POP" result="nodeArrayList3"/>
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode2" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode3" index="0" etype="PExp" from="nodeArrayList3"/>
    <action cmd="MAKENODE" result="pexpNode1" etype="ADivExp">
      <arg>pexpNode2</arg>
      <arg>pexpNode3</arg>
    </action>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="ATermFactor" index="8" leftside="3">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode1" index="0" etype="PExp" from="nodeArrayList1"/>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="ANumberTerm" index="9" leftside="4">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="tnumberNode2" index="0" etype="TNumber" from="nodeArrayList1"/>
    <action cmd="MAKENODE" result="pexpNode1" etype="ANumberExp">
      <arg>tnumberNode2</arg>
    </action>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="AExpTerm" index="10" leftside="4">
    <action cmd="POP" result="nodeArrayList3"/>
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="pexpNode1" index="0" etype="PExp" from="nodeArrayList2"/>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="ATextualTerm" index="11" leftside="4">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="MAKELIST" result="listNode3" etype="Textual"/>
    <action cmd="FETCHLIST" result="listNode2" index="0" etype="Textual" from="nodeArrayList1"/>
    <action cmd="ADDLIST" tolist="listNode3" list="listNode2"/>
    <action cmd="MAKENODE" result="pexpNode1" etype="ATextualExp">
      <arg>listNode3</arg>
    </action>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="ARandomX2Term" index="12" leftside="4">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="trandomNode2" index="0" etype="TRandom" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="trandomNode3" index="1" etype="TRandom" from="nodeArrayList1"/>
    <action cmd="MAKENODE" result="pexpNode1" etype="ARandomX2Exp">
      <arg>trandomNode2</arg>
      <arg>trandomNode3</arg>
    </action>
    <action cmd="RETURNNODE" etype="PExp" node="pexpNode1"/>
  </rule>
  <rule ename="AT1Textual" index="13" leftside="5">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="toneNode2" index="0" etype="TOne" from="nodeArrayList1"/>
    <action cmd="MAKENODE" result="ptextualNode1" etype="AT1Textual">
      <arg>toneNode2</arg>
    </action>
    <action cmd="RETURNNODE" etype="PTextual" node="ptextualNode1"/>
  </rule>
  <rule ename="AT2Textual" index="14" leftside="5">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="ttwoNode2" index="0" etype="TTwo" from="nodeArrayList1"/>
    <action cmd="MAKENODE" result="ptextualNode1" etype="AT2Textual">
      <arg>ttwoNode2</arg>
    </action>
    <action cmd="RETURNNODE" etype="PTextual" node="ptextualNode1"/>
  </rule>
  <rule ename="AT3Textual" index="15" leftside="5">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="tthreeNode2" index="0" etype="TThree" from="nodeArrayList1"/>
    <action cmd="MAKENODE" result="ptextualNode1" etype="AT3Textual">
      <arg>tthreeNode2</arg>
    </action>
    <action cmd="RETURNNODE" etype="PTextual" node="ptextualNode1"/>
  </rule>
  <rule ename="ARandomX2" index="16" leftside="6">
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="trandomNode1" index="0" etype="TRandom" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="trandomNode2" index="0" etype="TRandom" from="nodeArrayList2"/>
    <action cmd="RETURNNODE" etype="TRandom" node="trandomNode1"/>
    <action cmd="RETURNNODE" etype="TRandom" node="trandomNode2"/>
  </rule>
  <rule ename="ASemicolonSeparator" index="17" leftside="7">
    <action cmd="POP" result="nodeArrayList1"/>
  </rule>
  <rule ename="ATerminal$Textual" index="18" leftside="8">
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="MAKELIST" result="listNode2" etype="PTextual"/>
    <action cmd="FETCHNODE" result="ptextualNode1" index="0" etype="PTextual" from="nodeArrayList1"/>
    <action cmd="ADDNODE" etype="PTextual" tolist="listNode2" node="ptextualNode1"/>
    <action cmd="RETURNLIST" list="listNode2"/>
  </rule>
  <rule ename="ANonTerminal$Textual" index="19" leftside="8">
    <action cmd="POP" result="nodeArrayList2"/>
    <action cmd="POP" result="nodeArrayList1"/>
    <action cmd="MAKELIST" result="listNode3" etype="PTextual"/>
    <action cmd="FETCHLIST" result="listNode1" index="0" etype="PTextual" from="nodeArrayList1"/>
    <action cmd="FETCHNODE" result="ptextualNode2" index="0" etype="PTextual" from="nodeArrayList2"/>
    <action cmd="ADDLIST" tolist="listNode3" list="listNode1"/>
    <action cmd="ADDNODE" etype="PTextual" tolist="listNode3" node="ptextualNode2"/>
    <action cmd="RETURNLIST" list="listNode3"/>
  </rule>
  <parserdata>
    <actions>
      <row>
        <action from="-1" action="3" to="0"/>
        <action from="0" action="0" to="1"/>
        <action from="7" action="0" to="2"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
        <action from="11" action="0" to="6"/>
      </row>
      <row>
        <action from="-1" action="3" to="1"/>
        <action from="0" action="0" to="1"/>
        <action from="7" action="0" to="2"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
        <action from="11" action="0" to="6"/>
      </row>
      <row>
        <action from="-1" action="1" to="9"/>
      </row>
      <row>
        <action from="-1" action="1" to="13"/>
      </row>
      <row>
        <action from="-1" action="1" to="14"/>
      </row>
      <row>
        <action from="-1" action="1" to="15"/>
      </row>
      <row>
        <action from="-1" action="3" to="6"/>
        <action from="11" action="0" to="16"/>
      </row>
      <row>
        <action from="-1" action="3" to="7"/>
        <action from="12" action="2" to="-1"/>
      </row>
      <row>
        <action from="-1" action="1" to="0"/>
        <action from="6" action="0" to="17"/>
      </row>
      <row>
        <action from="-1" action="1" to="2"/>
        <action from="2" action="0" to="19"/>
        <action from="3" action="0" to="20"/>
      </row>
      <row>
        <action from="-1" action="1" to="5"/>
        <action from="4" action="0" to="21"/>
        <action from="5" action="0" to="22"/>
      </row>
      <row>
        <action from="-1" action="1" to="8"/>
      </row>
      <row>
        <action from="-1" action="1" to="18"/>
      </row>
      <row>
        <action from="-1" action="1" to="12"/>
      </row>
      <row>
        <action from="-1" action="1" to="11"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
      </row>
      <row>
        <action from="-1" action="3" to="15"/>
        <action from="1" action="0" to="24"/>
        <action from="2" action="0" to="19"/>
        <action from="3" action="0" to="20"/>
      </row>
      <row>
        <action from="-1" action="1" to="16"/>
      </row>
      <row>
        <action from="-1" action="1" to="17"/>
      </row>
      <row>
        <action from="-1" action="3" to="18"/>
        <action from="0" action="0" to="1"/>
        <action from="7" action="0" to="2"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
        <action from="11" action="0" to="6"/>
      </row>
      <row>
        <action from="-1" action="3" to="19"/>
        <action from="0" action="0" to="1"/>
        <action from="7" action="0" to="2"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
        <action from="11" action="0" to="6"/>
      </row>
      <row>
        <action from="-1" action="3" to="20"/>
        <action from="0" action="0" to="1"/>
        <action from="7" action="0" to="2"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
        <action from="11" action="0" to="6"/>
      </row>
      <row>
        <action from="-1" action="3" to="21"/>
        <action from="0" action="0" to="1"/>
        <action from="7" action="0" to="2"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
        <action from="11" action="0" to="6"/>
      </row>
      <row>
        <action from="-1" action="3" to="22"/>
        <action from="0" action="0" to="1"/>
        <action from="7" action="0" to="2"/>
        <action from="8" action="0" to="3"/>
        <action from="9" action="0" to="4"/>
        <action from="10" action="0" to="5"/>
        <action from="11" action="0" to="6"/>
      </row>
      <row>
        <action from="-1" action="1" to="19"/>
      </row>
      <row>
        <action from="-1" action="1" to="10"/>
      </row>
      <row>
        <action from="-1" action="1" to="1"/>
        <action from="2" action="0" to="19"/>
        <action from="3" action="0" to="20"/>
      </row>
      <row>
        <action from="-1" action="1" to="3"/>
        <action from="4" action="0" to="21"/>
        <action from="5" action="0" to="22"/>
      </row>
      <row>
        <action from="-1" action="1" to="4"/>
        <action from="4" action="0" to="21"/>
        <action from="5" action="0" to="22"/>
      </row>
      <row>
        <action from="-1" action="1" to="6"/>
      </row>
      <row>
        <action from="-1" action="1" to="7"/>
      </row>
    </actions>
    <gotos>
      <row>
        <goto from="-1" to="7"/>
      </row>
      <row>
        <goto from="-1" to="8"/>
      </row>
      <row>
        <goto from="-1" to="9"/>
        <goto from="1" to="15"/>
        <goto from="18" to="25"/>
      </row>
      <row>
        <goto from="-1" to="10"/>
        <goto from="19" to="26"/>
        <goto from="20" to="27"/>
      </row>
      <row>
        <goto from="-1" to="11"/>
        <goto from="21" to="28"/>
        <goto from="22" to="29"/>
      </row>
      <row>
        <goto from="-1" to="12"/>
        <goto from="14" to="23"/>
      </row>
      <row>
        <goto from="-1" to="13"/>
      </row>
      <row>
        <goto from="-1" to="18"/>
      </row>
      <row>
        <goto from="-1" to="14"/>
      </row>
    </gotos>
    <errors>
      <i>0</i><i>0</i><i>1</i><i>2</i><i>2</i><i>2</i><i>3</i><i>4</i><i>5</i><i>6</i><i>1</i><i>1</i><i>2</i><i>1</i><i>2</i><i>7</i><i>1</i><i>0</i><i>0</i><i>0</i><i>0</i><i>0</i><i>0</i><i>2</i><i>1</i><i>6</i><i>1</i><i>1</i><i>1</i><i>1</i>
    </errors>
    <error_messages>
      <msg>expecting: '(', number, 'one', 'two', 'three', 'random_digit'</msg>
      <msg>expecting: ')', '+', '-', '*', '/', ';', EOF</msg>
      <msg>expecting: ')', '+', '-', '*', '/', ';', 'one', 'two', 'three', EOF</msg>
      <msg>expecting: 'random_digit'</msg>
      <msg>expecting: EOF</msg>
      <msg>expecting: ';', EOF</msg>
      <msg>expecting: '+', '-', ';', EOF</msg>
      <msg>expecting: ')', '+', '-'</msg>
    </error_messages>
  </parserdata>
</parser>
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
<xsl:output method="text"/>

<xsl:template match="parser">
package <xsl:value-of select="@package"/>.analysis;

import java.util.*;
import <xsl:value-of select="@package"/>.node.*;

public class MyDepthFirstAdapter extends AnalysisAdapter
{
    public void inStart(Start node)
    {
        defaultIn(node);
    }

    public void outStart(Start node)
    {
        defaultOut(node);
    }

    public void defaultIn(Node node)
    {
    }

    public void defaultOut(Node node)
    {
    }

    public void caseStart(Start node)
    {
        inStart(node);
        node.get<xsl:value-of select="production/@ename"/>().apply(this);
        node.getEOF().apply(this);
        outStart(node);
    }

<xsl:apply-templates select="//alt"/>
};
</xsl:template>

<xsl:template match="alt">
    void case<xsl:value-of select="@ename"/> (<xsl:value-of select="@ename"/> node)
    {
      in<xsl:value-of select="@ename"/> (node);<xsl:apply-templates select="elem"/>
      out<xsl:value-of select="@ename"/> (node);
    }

    void in<xsl:value-of select="@ename"/> (<xsl:value-of select="@ename"/> node)
    {
      defaultIn(node);
    }

    void out<xsl:value-of select="@ename"/> (<xsl:value-of select="@ename"/> node)
    {
      defaultOut(node);
    }
</xsl:template>

<xsl:template match="elem[@is_list='false']">
      if ( node.get<xsl:value-of select="@ename"/>() != null )
      {
          node.get<xsl:value-of select="@ename"/>().apply(this);
      }
</xsl:template>

<xsl:template match="elem[@is_list='true']">
      {
          Object temp[] = node.get<xsl:value-of select="@ename"/>().toArray();
          for(int i = 0; i &lt; temp.length; i++)
          {
              ((<xsl:value-of select="@etype"/>) temp[i]).apply(this);
          }
      }
</xsl:template>

</xsl:stylesheet>

package expression.analysis;

import java.util.*;
import expression.node.*;

public class MyDepthFirstAdapter extends AnalysisAdapter
{
    public void inStart(Start node)
    {
        defaultIn(node);
    }

    public void outStart(Start node)
    {
        defaultOut(node);
    }

    public void defaultIn(Node node)
    {
    }

    public void defaultOut(Node node)
    {
    }

    public void caseStart(Start node)
    {
        inStart(node);
        node.getPGrammar().apply(this);
        node.getEOF().apply(this);
        outStart(node);
    }


    void caseAGrammar (AGrammar node)
    {
      inAGrammar (node);
      {
          Object temp[] = node.getExp().toArray();
          for(int i = 0; i < temp.length; i++)
          {
              ((PExp) temp[i]).apply(this);
          }
      }

      outAGrammar (node);
    }

    void inAGrammar (AGrammar node)
    {
      defaultIn(node);
    }

    void outAGrammar (AGrammar node)
    {
      defaultOut(node);
    }

    void caseAPlusExp (APlusExp node)
    {
      inAPlusExp (node);
      if ( node.getL() != null )
      {
          node.getL().apply(this);
      }

      if ( node.getR() != null )
      {
          node.getR().apply(this);
      }

      outAPlusExp (node);
    }

    void inAPlusExp (APlusExp node)
    {
      defaultIn(node);
    }

    void outAPlusExp (APlusExp node)
    {
      defaultOut(node);
    }

    void caseAMinusExp (AMinusExp node)
    {
      inAMinusExp (node);
      if ( node.getL() != null )
      {
          node.getL().apply(this);
      }

      if ( node.getR() != null )
      {
          node.getR().apply(this);
      }

      outAMinusExp (node);
    }

    void inAMinusExp (AMinusExp node)
    {
      defaultIn(node);
    }

    void outAMinusExp (AMinusExp node)
    {
      defaultOut(node);
    }

    void caseADivExp (ADivExp node)
    {
      inADivExp (node);
      if ( node.getL() != null )
      {
          node.getL().apply(this);
      }

      if ( node.getR() != null )
      {
          node.getR().apply(this);
      }

      outADivExp (node);
    }

    void inADivExp (ADivExp node)
    {
      defaultIn(node);
    }

    void outADivExp (ADivExp node)
    {
      defaultOut(node);
    }

    void caseAMultExp (AMultExp node)
    {
      inAMultExp (node);
      if ( node.getL() != null )
      {
          node.getL().apply(this);
      }

      if ( node.getR() != null )
      {
          node.getR().apply(this);
      }

      outAMultExp (node);
    }

    void inAMultExp (AMultExp node)
    {
      defaultIn(node);
    }

    void outAMultExp (AMultExp node)
    {
      defaultOut(node);
    }

    void caseATextualExp (ATextualExp node)
    {
      inATextualExp (node);
      {
          Object temp[] = node.getTextual().toArray();
          for(int i = 0; i < temp.length; i++)
          {
              ((PTextual) temp[i]).apply(this);
          }
      }

      outATextualExp (node);
    }

    void inATextualExp (ATextualExp node)
    {
      defaultIn(node);
    }

    void outATextualExp (ATextualExp node)
    {
      defaultOut(node);
    }

    void caseARandomX2Exp (ARandomX2Exp node)
    {
      inARandomX2Exp (node);
      if ( node.getR1() != null )
      {
          node.getR1().apply(this);
      }

      if ( node.getR2() != null )
      {
          node.getR2().apply(this);
      }

      outARandomX2Exp (node);
    }

    void inARandomX2Exp (ARandomX2Exp node)
    {
      defaultIn(node);
    }

    void outARandomX2Exp (ARandomX2Exp node)
    {
      defaultOut(node);
    }

    void caseANumberExp (ANumberExp node)
    {
      inANumberExp (node);
      if ( node.getNumber() != null )
      {
          node.getNumber().apply(this);
      }

      outANumberExp (node);
    }

    void inANumberExp (ANumberExp node)
    {
      defaultIn(node);
    }

    void outANumberExp (ANumberExp node)
    {
      defaultOut(node);
    }

    void caseAT1Textual (AT1Textual node)
    {
      inAT1Textual (node);
      if ( node.getOne() != null )
      {
          node.getOne().apply(this);
      }

      outAT1Textual (node);
    }

    void inAT1Textual (AT1Textual node)
    {
      defaultIn(node);
    }

    void outAT1Textual (AT1Textual node)
    {
      defaultOut(node);
    }

    void caseAT2Textual (AT2Textual node)
    {
      inAT2Textual (node);
      if ( node.getTwo() != null )
      {
          node.getTwo().apply(this);
      }

      outAT2Textual (node);
    }

    void inAT2Textual (AT2Textual node)
    {
      defaultIn(node);
    }

    void outAT2Textual (AT2Textual node)
    {
      defaultOut(node);
    }

    void caseAT3Textual (AT3Textual node)
    {
      inAT3Textual (node);
      if ( node.getThree() != null )
      {
          node.getThree().apply(this);
      }

      outAT3Textual (node);
    }

    void inAT3Textual (AT3Textual node)
    {
      defaultIn(node);
    }

    void outAT3Textual (AT3Textual node)
    {
      defaultOut(node);
    }

};