コード例 #1
0
ファイル: CExecSQLCommit.java プロジェクト: rplandgraf/naca
  protected boolean DoParsing() {
    CBaseToken tok = GetCurrentToken();
    if (tok.GetKeyword() == CCobolKeywordList.COMMIT) {
      tok = GetNext();
    }

    if (tok.GetKeyword() == CCobolKeywordList.WORK) {
      tok = GetNext();
    }
    return true;
  }
コード例 #2
0
  private boolean CustomParsing() {
    CBaseToken tok = GetCurrentToken();
    if (tok.GetKeyword() == null) return false;
    CFPacElement el = null;
    if (tok.GetKeyword().m_Name.startsWith("IPF")) {
      CFPacInputFile file = new CFPacInputFile(tok.getLine());
      el = file;
      m_arrInputFiles.add(file);
    } else if (tok.GetKeyword().m_Name.startsWith("OPF")) {
      CFPacOutputFile file = new CFPacOutputFile(tok.getLine());
      m_arrOutputFiles.add(file);
      el = file;
    } else if (tok.GetKeyword().m_Name.startsWith("UPF")) {
      CFPacUpdateFile file = new CFPacUpdateFile(tok.getLine());
      m_arrUpdateFiles.add(file);
      el = file;
    } else if (tok.GetKeyword() == CFPacKeywordList.PARM) {
      tok = GetNext();
      if (tok.GetType() == CTokenType.EQUALS) {
        tok = GetNext();
        boolean bDone = false;
        while (!bDone) {
          if (tok.GetType() == CTokenType.CONSTANT) {
            CConstantTerminal term = new CConstantTerminal(tok.GetValue());
            m_arrParams.add(term);
          } else {
            Transcoder.logError(tok.getLine(), "Expecting CONSTANT after PARM");
            return false;
          }

          tok = GetNext();
          if (tok.GetType() == CTokenType.COMMA) {
            tok = GetNext();
          } else {
            bDone = true;
          }
        }
      } else {
        Transcoder.logError(tok.getLine(), "Expecting '=' after PARM");
        return false;
      }
    } else return false;

    if (el != null) {
      if (!Parse(el)) return false;
    }
    return true;
  }
コード例 #3
0
ファイル: CFPacElement.java プロジェクト: rplandgraf/naca
 protected CExpression ReadCondition() {
   CExpression exp = ReadAndCondition();
   CBaseToken tok = GetCurrentToken();
   if (tok.GetKeyword() == CFPacKeywordList.OR) {
     StepNext();
     CExpression exp2 = ReadCondition();
     CCondOrStatement st = new CCondOrStatement(tok.getLine(), exp, exp2);
     return st;
   }
   return exp;
 }
コード例 #4
0
ファイル: CElseBloc.java プロジェクト: rplandgraf/naca
 /* (non-Javadoc)
  * @see parser.CLanguageElement#ExportCustom(org.w3c.dom.Document)
  */
 protected boolean DoParsing(CFlag fCheckForNextSentence) {
   CBaseToken tok = GetCurrentToken();
   if (tok.GetType() == CTokenType.KEYWORD && tok.GetKeyword() == CCobolKeywordList.ELSE) {
     GetNext();
   }
   if (!super.DoParsing()) {
     return false;
   }
   if (fCheckForNextSentence != null) {
     fCheckForNextSentence.Set(m_fCheckForNextSentence.ISSet());
   }
   tok = GetCurrentToken();
   if (tok.GetType() == CTokenType.DOT) { // end of IF statement
     m_nEndLine = tok.getLine();
     return true;
   } else if (tok.GetKeyword() == CCobolKeywordList.END_IF) {
     m_nEndLine = tok.getLine();
     StepNext();
   }
   return true;
 }
コード例 #5
0
ファイル: CExecCICSConnect.java プロジェクト: rplandgraf/naca
  protected boolean DoParsing() {
    CBaseToken tok = GetCurrentToken();
    // if (tok.GetKeyword() == CCobolKeywordList.)
    {
      tok = GetNext();
    }

    String cs = "";
    tok = GetCurrentToken();
    while (tok.GetKeyword() != CCobolKeywordList.END_EXEC) {
      cs += tok.GetDisplay() + " ";
      tok = GetNext();
    }

    if (tok.GetKeyword() != CCobolKeywordList.END_EXEC) {
      Transcoder.logError(getLine(), "Error while parsing EXEC CICS CONNECT");
      return false;
    }
    StepNext();
    return true;
  }
コード例 #6
0
ファイル: CFPacElement.java プロジェクト: rplandgraf/naca
 protected CTerminal ReadTerminal() {
   CBaseToken tok = GetCurrentToken();
   if (tok.GetKeyword() == CFPacKeywordList.C) {
     tok = GetNext();
     if (tok.GetType() == CTokenType.STRING) {
       String cs = tok.GetValue();
       CTerminal term = new CStringTerminal(cs);
       StepNext();
       return term;
     } else {
       Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'C'");
       return null;
     }
   } else if (tok.GetKeyword() == CFPacKeywordList.C) {
     String cs = tok.GetValue();
     CTerminal term = new CStringTerminal(cs);
     StepNext();
     return term;
   } else if (tok.GetKeyword() == CFPacKeywordList.P) {
     tok = GetNext();
     if (tok.GetType() == CTokenType.STRING) {
       String cs = tok.GetValue();
       CTerminal term = new CNumberTerminal(cs);
       StepNext();
       return term;
     } else {
       Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'P'");
       return null;
     }
   } else if (tok.GetKeyword() == CFPacKeywordList.F) {
     tok = GetNext();
     if (tok.GetType() == CTokenType.STRING) {
       String cs = tok.GetValue();
       CTerminal term = new CNumberTerminal(cs);
       StepNext();
       return term;
     } else {
       Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'F'");
       return null;
     }
   } else if (tok.GetKeyword() == CFPacKeywordList.X) {
     tok = GetNext();
     if (tok.GetType() == CTokenType.STRING) {
       String cs = tok.GetValue();
       CTerminal term = new CNumberTerminal("0x" + cs);
       StepNext();
       return term;
     } else {
       Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'X'");
       return null;
     }
   } else if (tok.GetType() == CTokenType.NUMBER) {
     CAddressTerminal term = new CAddressTerminal(tok.GetValue());
     tok = GetNext();
     return term;
   } else if (tok.GetType() == CTokenType.IDENTIFIER) {
     CIdentifier id = ReadIdentifier();
     if (id != null) {
       CIdentifierTerminal term = new CIdentifierTerminal(id);
       return term;
     } else {
       // ...
     }
   } else if (tok.GetType() == CTokenType.STRING) {
     String cs = tok.GetValue();
     CTerminal term = new CStringTerminal(cs);
     StepNext();
     return term;
   } else {
     Transcoder.logError(
         tok.getLine(), "Unexpecting token while reading terminal : " + tok.toString());
     return null;
   }
   return null;
 }
コード例 #7
0
ファイル: CFPacElement.java プロジェクト: rplandgraf/naca
  protected CExpression ReadExpression() {
    CBaseToken tok = GetCurrentToken();
    CFPacGenericExpression exp = new CFPacGenericExpression(tok.getLine());
    boolean bOk = true;
    while (bOk) {
      tok = GetCurrentToken();
      if (tok.GetKeyword() == CFPacKeywordList.P) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.STRING) {
          String cs = tok.GetValue();
          CTerminal term = new CNumberTerminal(cs);
          exp.AddTerm(new CTermExpression(tok.getLine(), term));
        } else {
          Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'P'");
          return null;
        }
        tok = GetNext();
      } else if (tok.GetKeyword() == CFPacKeywordList.C) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.STRING) {
          String cs = tok.GetValue();
          CTerminal term = new CStringTerminal(cs);
          exp.AddTerm(new CTermExpression(tok.getLine(), term));
        } else {
          Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'C'");
          return null;
        }
        tok = GetNext();
      } else if (tok.GetType() == CTokenType.STRING) {
        String cs = tok.GetValue();
        CTerminal term = new CStringTerminal(cs);
        exp.AddTerm(new CTermExpression(tok.getLine(), term));
        tok = GetNext();
      } else if (tok.GetKeyword() == CFPacKeywordList.X) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.STRING) {
          String cs = tok.GetValue();
          CTerminal term = new CNumberTerminal("0x" + cs);
          exp.AddTerm(new CTermExpression(tok.getLine(), term));
        } else {
          Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'X'");
          return null;
        }
        tok = GetNext();
      } else if (tok.GetKeyword() == CFPacKeywordList.E) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.STRING) {
          String cs = tok.GetValue();
          CTerminal term = new CStringTerminal(cs);
          exp.AddTerm(new CTermExpression(tok.getLine(), term));
        } else {
          Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'E'");
          return null;
        }
        tok = GetNext();
      } else if (tok.GetKeyword() == CFPacKeywordList.F) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.STRING) {
          String cs = tok.GetValue();
          CTerminal term = new CNumberTerminal(cs);
          exp.AddTerm(new CTermExpression(tok.getLine(), term));
        } else {
          Transcoder.logError(tok.getLine(), "Expecting 'STRING' after 'F'");
          return null;
        }
        tok = GetNext();
      } else if (tok.GetKeyword() == CFPacKeywordList.EQ
          || tok.GetKeyword() == CFPacKeywordList.NE
          || tok.GetKeyword() == CFPacKeywordList.GE
          || tok.GetKeyword() == CFPacKeywordList.GT
          || tok.GetKeyword() == CFPacKeywordList.LE
          || tok.GetKeyword() == CFPacKeywordList.LT
          || tok.GetKeyword() == CFPacKeywordList.NUMERIC
          || tok.GetKeyword() == CFPacKeywordList.SPACE) {
        exp.SetKeyword(tok.GetKeyword());
        tok = GetNext();
      } else if (tok.GetType() == CTokenType.NUMBER) {
        CTerminal term = new CAddressTerminal(tok.GetValue());
        CExpression e = new CTermExpression(tok.getLine(), term);
        tok = GetNext();
        if (tok.GetType() == CTokenType.PLUS) {
          tok = GetNext();
          CExpression exp2 = ReadTerminalExpression();
          if (exp2 == null) {
            Transcoder.logError(tok.getLine(), "Expecting expression after '+'");
            return null;
          }
          CSumExpression sum =
              new CSumExpression(tok.getLine(), e, exp2, CSumExpression.CSumType.ADD);
          exp.AddTerm(sum);
        } else {
          exp.AddTerm(e);
        }
      } else if (tok.GetType() == CTokenType.IDENTIFIER) {
        CIdentifier id = new CIdentifier(tok.GetValue());
        tok = GetNext();
        if (tok.GetType() == CTokenType.MINUS) {
          tok = GetNext();
          if (tok.GetType() == CTokenType.NUMBER) {
            CExpression e = new CTermExpression(0, new CAddressTerminal(tok.GetValue()));
            // id.SetSubStringReference(exp, null) ;
            CTerminal term = new CIdentifierTerminal(id);
            exp.AddTerm(new CTermExpression(tok.getLine(), term));
            exp.AddTerm(e);
            tok = GetNext();
          } else {
            Transcoder.logError(
                tok.getLine(), "Expecting number instead of token : " + tok.toString());
            return null;
          }
        } else if (tok.GetType() == CTokenType.PLUS) {
          tok = GetNext();
          CExpression e = ReadTerminalExpression();
          if (e == null) {
            Transcoder.logError(tok.getLine(), "Expecting expression after '+'");
            return null;
          }
          CSumExpression sum =
              new CSumExpression(
                  tok.getLine(),
                  new CTermExpression(tok.getLine(), new CIdentifierTerminal(id)),
                  e,
                  CSumExpression.CSumType.ADD);
          exp.AddTerm(sum);
        } else if (tok.GetType() == CTokenType.COMMA) {
          CTerminal term = new CIdentifierTerminal(id);
          exp.AddTerm(new CTermExpression(tok.getLine(), term));
        } else {
          Transcoder.logError(tok.getLine(), "Unexpecting token : " + tok.toString());
          return null;
        }
      }

      tok = GetCurrentToken();
      if (tok.GetType() == CTokenType.COMMA) {
        tok = GetNext();
      } else {
        bOk = false;
      }
    }

    return exp;
  }
コード例 #8
0
  protected boolean DoParsing() {
    CBaseToken tok = GetCurrentToken();
    if (tok.GetKeyword() == CCobolKeywordList.READPREV) {
      tok = GetNext();
    }

    boolean bDone = false;
    while (!bDone) {
      tok = GetCurrentToken();
      if (tok.GetKeyword() == CCobolKeywordList.FILE && m_ReadType == null) {
        m_ReadType = CCobolKeywordList.FILE;
        tok = GetNext();
        if (tok.GetType() == CTokenType.LEFT_BRACKET) {
          tok = GetNext();
          m_FileName = ReadTerminal();
          tok = GetCurrentToken();
          if (tok.GetType() == CTokenType.RIGHT_BRACKET) {
            tok = GetNext();
          }
        }
      } else if (tok.GetKeyword() == CCobolKeywordList.DATASET && m_ReadType == null) {
        m_ReadType = CCobolKeywordList.DATASET;
        tok = GetNext();
        if (tok.GetType() == CTokenType.LEFT_BRACKET) {
          tok = GetNext();
          m_FileName = ReadTerminal();
          tok = GetCurrentToken();
          if (tok.GetType() == CTokenType.RIGHT_BRACKET) {
            tok = GetNext();
          }
        }
      } else if (tok.GetKeyword() == CCobolKeywordList.INTO) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.LEFT_BRACKET) {
          tok = GetNext();
          m_DataInto = ReadIdentifier();
          tok = GetCurrentToken();
          if (tok.GetType() == CTokenType.RIGHT_BRACKET) {
            tok = GetNext();
          }
        }
      } else if (tok.GetValue().equals("RIDFLD")) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.LEFT_BRACKET) {
          tok = GetNext();
          m_RecIDField = ReadIdentifier();
          tok = GetCurrentToken();
          if (tok.GetType() == CTokenType.RIGHT_BRACKET) {
            tok = GetNext();
          }
        }
      } else if (tok.GetKeyword() == CCobolKeywordList.LENGTH) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.LEFT_BRACKET) {
          tok = GetNext();
          m_Length = ReadTerminal();
          tok = GetCurrentToken();
          if (tok.GetType() == CTokenType.RIGHT_BRACKET) {
            tok = GetNext();
          }
        }
      } else if (tok.GetValue().equals("KEYLENGTH")) {
        tok = GetNext();
        if (tok.GetType() == CTokenType.LEFT_BRACKET) {
          tok = GetNext();
          m_KeyLength = ReadTerminal();
          tok = GetCurrentToken();
          if (tok.GetType() == CTokenType.RIGHT_BRACKET) {
            tok = GetNext();
          }
        }
      } else {
        bDone = true;
      }
    }

    if (tok.GetKeyword() != CCobolKeywordList.END_EXEC) {
      Transcoder.logError(tok.getLine(), "Error while parsing EXEC CICS READ");
      return false;
    }
    StepNext();
    return true;
  }
コード例 #9
0
  /* (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;
  }
コード例 #10
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;
    }
  }