コード例 #1
0
 @Override
 protected CParser<CMapSetElement> doParsing(CTokenList lst) {
   CBMSParser parser = new CBMSParser();
   if (parser.StartParsing(lst)) {
     CGlobalEntityCounter.GetInstance().CountBMSFile();
     return parser;
   } else {
     Transcoder.logError("BMS parsing failed");
     return null;
   }
 }
コード例 #2
0
ファイル: CWorkingValueEntry.java プロジェクト: charleso/naca
  /* (non-Javadoc)
   * @see parser.CLanguageElement#Parse(lexer.CTokenList)
   */
  protected boolean DoParsing() {
    CBaseToken tok88 = GetCurrentToken();
    if (tok88.GetType() != CTokenType.NUMBER || !tok88.GetValue().equals("88")) {
      Transcoder.logError(getLine(), "Expecting '88' keyword");
      return false;
    }
    CGlobalEntityCounter.GetInstance().CountCobolVerb("NAMED_CONDITION");

    CBaseToken tok = GetNext();
    if (tok.GetType() != CTokenType.IDENTIFIER) {
      Transcoder.logError(getLine(), "Expecting an identifier after '88' keyword");
      return false;
    }
    m_csIdentifier = tok.GetValue();

    tok = GetNext();
    if (tok.GetKeyword() != CCobolKeywordList.VALUE
        && tok.GetKeyword() != CCobolKeywordList.VALUES) {
      Transcoder.logError(getLine(), "Expecting 'VALUE' keyword");
      return false;
    }

    tok = GetNext();
    if (tok.GetKeyword() == CCobolKeywordList.IS || tok.GetKeyword() == CCobolKeywordList.ARE) {
      tok = GetNext();
    }
    boolean bDone = false;
    while (!bDone) {
      CBaseToken tokVal = GetCurrentToken();
      CTerminal val;
      if (tokVal.GetType() == CTokenType.COMMA) {
        tokVal = GetNext();
      }
      if (tokVal.GetType() == CTokenType.STRING
          || tokVal.GetType() == CTokenType.NUMBER
          || tokVal.GetType() == CTokenType.CONSTANT
          || tokVal.GetType() == CTokenType.MINUS) {
        val = ReadTerminal();
        m_arrValues.addElement(val);

        CBaseToken tokNext = GetCurrentToken();
        if (tokNext.GetType() == CTokenType.COMMA) {
          m_arrValues.addElement(
              val); // values are intervals, so for a single value, it is added twice, as an
                    // interval of one single value
          GetNext(); // consume ","
        } else if (tokNext.GetType() == CTokenType.STRING
            || tokNext.GetType() == CTokenType.NUMBER
            || tokNext.GetType() == CTokenType.CONSTANT) {
          m_arrValues.addElement(
              val); // values are intervals, so for a single value, it is added twice, as an
                    // interval of one single value
        } else if (tokNext.GetKeyword() == CCobolKeywordList.THROUGH
            || tokNext.GetKeyword() == CCobolKeywordList.THRU) {
          tokNext = GetNext();
          if (tokNext.GetType() == CTokenType.STRING
              || tokNext.GetType() == CTokenType.NUMBER
              || tokNext.GetType() == CTokenType.CONSTANT) {
            val = ReadTerminal();
            m_arrValues.addElement(val);
          } else {
            Transcoder.logError(tokNext.getLine(), "Unexpecting token : " + tokNext.GetValue());
            return false;
          }
        } else {
          m_arrValues.addElement(
              val); // values are intervals, so for a single value, it is added twice, as an
                    // interval of one single value
          bDone = true;
        }
      } else {
        bDone = true;
      }
    }
    tok = GetCurrentToken();
    if (tok.GetType() == CTokenType.DOT) {
      GetNext(); // consume DOT at the end of the statement
    }
    if (m_arrValues.size() > 0) {
      return true;
    } else {
      return false;
    }
  }