/* (non-Javadoc)
   * @see parser.CLanguageElement#Parse(lexer.CTokenList)
   */
  protected boolean DoParsing() {
    CProcedureSection curSection = null;
    boolean bDone = false;
    while (!bDone) {
      CBaseToken tok = GetCurrentToken();
      if (tok == null) {
        return true;
      }
      if (tok.GetType() == CTokenType.IDENTIFIER
          || tok.GetType() == CTokenType.NUMBER) { // maybe a label ?
        // m_ProcedureDivisionBloc = new CBaseProcedure(getLine()); // PJD: Uncomment this line if
        // we wanted to always have ProcedureDivision() method. It's not needed if we just have a
        // paragraph or section immediatelly after the PROCEDURE DIVISION
        String csLabel = tok.GetValue();
        GetNext();

        CBaseToken tokSection = GetCurrentToken();
        if (tokSection.IsKeyword()
            && tokSection.GetKeyword()
                == CCobolKeywordList.SECTION) { // maybe the starting of a section
          CBaseToken tokDot = GetNext();
          if (tokDot.GetType() != CTokenType.DOT) {
            Transcoder.logError(getLine(), "Expecting 'DOT'");
            return false;
          } else {
            GetNext();
          }
          curSection = new CProcedureSection(csLabel, tok.getLine());
          AddChild(curSection);
          if (!Parse(curSection)) {
            return false;
          }
        } else if (tokSection.IsKeyword()
            && tokSection.GetKeyword()
                == CCobolKeywordList.LABEL_SENTENCE) { // maybe the starting of a section
          CBaseToken tokDot = GetNext();
          if (tokDot.GetType() != CTokenType.DOT) {
            Transcoder.logError(getLine(), "Expecting 'DOT'");
            return false;
          } else {
            GetNext();
          }
          // CProcedureLabelSentence labelSentence = new CProcedureLabelSentence(csLabel,
          // tok.getLine()) ;
          curSection = new CProcedureSection(csLabel, tok.getLine());
          curSection.setForcedLabelSentence();
          AddChild(curSection);
          if (!Parse(curSection)) {
            return false;
          }
        } else if (tokSection.GetType() == CTokenType.DOT) {
          CProcedure eProc = new CProcedure(csLabel, tokSection.getLine());
          if (curSection == null) {
            AddChild(eProc);
          } else {
            curSection.AddProcedure(eProc);
          }
          if (!Parse(eProc)) {
            return false;
          }
        } else {
          Transcoder.logError(tokSection.getLine(), "Unexpecting token : " + tokSection.GetValue());
          return false;
        }
      } else if (tok.GetType() == CTokenType.KEYWORD) {
        m_ProcedureDivisionBloc = new CBaseProcedure(getLine());
        CBaseToken tok1 = GetCurrentToken();
        if (!Parse(m_ProcedureDivisionBloc)) {
          return false;
        }
        CBaseToken tok2 = GetCurrentToken();
        if (tok2 == tok1) {
          Transcoder.logError(tok1.getLine(), "Token not parsed : " + tok1.GetValue());
          GetNext();
        }
        //				else if (tok2.GetType() == CTokenType.DOT)
        //				{
        //					GetNext() ;
        //				}
      } else if (tok.GetType() == CTokenType.END_OF_BLOCK) {
        GetNext();
      } else {
        Transcoder.logError(tok.getLine(), "Unexpecting token : " + tok.GetValue());
        GetNext();
      }
    }
    return true;
  }