<class>
  <keyword > class </keyword>
  <identifier class, defined> Main </identifier>
  <symbol > { </symbol>
  <subroutineDec>
    <keyword > void </keyword>
    <identifier subroutine, defined> main </identifier>
    <symbol > ( </symbol>
    <parameterList>
    </parameterList>
    <symbol > ) </symbol>
    <subroutineBody>
      <symbol > { </symbol>
      <varDec>
        <keyword > var </keyword>
        <identifier > Array </identifier>
        <identifier name=a type=Array kind=Var index=0 declared> a </identifier>
        <symbol > ; </symbol>
      </varDec>
      <varDec>
        <keyword > var </keyword>
        <keyword > int </keyword>
        <identifier name=length type=int kind=Var index=1 declared> length </identifier>
        <symbol > ; </symbol>
      </varDec>
      <varDec>
        <keyword > var </keyword>
        <keyword > int </keyword>
        <identifier name=i type=int kind=Var index=2 declared> i </identifier>
        <symbol > , </symbol>
        <identifier name=sum type=int kind=Var index=3 declared> sum </identifier>
        <symbol > ; </symbol>
      </varDec>
      <statements>
        <letStatement>
          <keyword > let </keyword>
          <identifier name=length type=int kind=Var index=1 used> length </identifier>
          <symbol > = </symbol>
          <expression>
            <term>
              <identifier class, used> Keyboard </identifier>
              <symbol > . </symbol>
              <identifier function, used> readInt </identifier>
              <symbol > ( </symbol>
              <symbol > ) </symbol>
            </term>
          </expression>
          <symbol > ; </symbol>
        </letStatement>
        <letStatement>
          <keyword > let </keyword>
          <identifier name=a type=Array kind=Var index=0 used> a </identifier>
          <symbol > = </symbol>
          <expression>
            <term>
              <identifier class, used> Array </identifier>
              <symbol > . </symbol>
              <identifier function, used> new </identifier>
              <symbol > ( </symbol>
              <symbol > ) </symbol>
            </term>
          </expression>
          <symbol > ; </symbol>
        </letStatement>
        <letStatement>
          <keyword > let </keyword>
          <identifier name=i type=int kind=Var index=2 used> i </identifier>
          <symbol > = </symbol>
          <expression>
            <term>
              <integerConstant > 0 </integerConstant>
            </term>
          </expression>
          <symbol > ; </symbol>
        </letStatement>
        <whileStatement>
          <keyword > while </keyword>
          <symbol > ( </symbol>
          <expression>
            <term>
              <identifier name=i type=int kind=Var index=2 used> i </identifier>
            </term>
            <symbol > &lt; </symbol>
            <term>
              <identifier name=length type=int kind=Var index=1 used> length </identifier>
            </term>
          </expression>
          <symbol > ) </symbol>
          <symbol > { </symbol>
          <statements>
            <letStatement>
              <keyword > let </keyword>
              <identifier name=a type=Array kind=Var index=0 used> a </identifier>
              <symbol > [ </symbol>
              <expression>
                <term>
                  <identifier name=i type=int kind=Var index=2 used> i </identifier>
                </term>
              </expression>
              <symbol > ] </symbol>
              <symbol > = </symbol>
              <expression>
                <term>
                  <identifier class, used> Keyboard </identifier>
                  <symbol > . </symbol>
                  <identifier function, used> readInt </identifier>
                  <symbol > ( </symbol>
                  <symbol > ) </symbol>
                </term>
              </expression>
              <symbol > ; </symbol>
            </letStatement>
            <letStatement>
              <keyword > let </keyword>
              <identifier name=sum type=int kind=Var index=3 used> sum </identifier>
              <symbol > = </symbol>
              <expression>
                <term>
                  <identifier name=sum type=int kind=Var index=3 used> sum </identifier>
                </term>
                <symbol > + </symbol>
                <term>
                  <symbol > [ </symbol>
                  <expression>
                    <term>
                      <identifier name=i type=int kind=Var index=2 used> i </identifier>
                    </term>
                  </expression>
                  <symbol > ] </symbol>
                </term>
              </expression>
              <symbol > ; </symbol>
            </letStatement>
            <letStatement>
              <keyword > let </keyword>
              <identifier name=i type=int kind=Var index=2 used> i </identifier>
              <symbol > = </symbol>
              <expression>
                <term>
                  <identifier name=i type=int kind=Var index=2 used> i </identifier>
                </term>
                <symbol > + </symbol>
                <term>
                  <integerConstant > 1 </integerConstant>
                </term>
              </expression>
              <symbol > ; </symbol>
            </letStatement>
          </statements>
          <symbol > } </symbol>
        </whileStatement>
        <doStatement>
          <keyword > do </keyword>
          <identifier class, used> Output </identifier>
          <symbol > . </symbol>
          <identifier function, used> printString </identifier>
          <symbol > ( </symbol>
          <symbol > ) </symbol>
          <symbol > ; </symbol>
        </doStatement>
        <doStatement>
          <keyword > do </keyword>
          <identifier class, used> Output </identifier>
          <symbol > . </symbol>
          <identifier function, used> printInt </identifier>
          <symbol > ( </symbol>
          <symbol > ) </symbol>
          <symbol > ; </symbol>
        </doStatement>
        <returnStatement>
          <keyword > return </keyword>
          <symbol > ; </symbol>
        </returnStatement>
      </statements>
      <symbol > } </symbol>
    </subroutineBody>
  </subroutineDec>
  <symbol > } </symbol>
</class>
