TypeCobolTeam / TypeCobol

TypeCobol is an Incremental Cobol parser for IBM Enterprise Cobol 6 for zOS syntax. TypeCobol is also an extension of Cobol 85 language which can then be converted to Cobol85.
Other
78 stars 26 forks source link

Compiler error in semantic check when using CFG analyzer for program with SQL Statement in LINKAGE SECTION #1849

Open alvaro-vantis-pt opened 3 years ago

alvaro-vantis-pt commented 3 years ago

Program with SQL Statements in LINKAGE gives the following error in Semantic Check step:

Synntax error : extraneous input 'EXECSQLDECLARE tablename1 TABLE ( num DECIMAL(45) NOT NULL, str VARCHAR(256) NOT NULL )END-EXEC' expecting {ProgramIdentification, ProgramEnd, ClassIdentification, MethodEnd, ProcedureDivisionHeader, DataDescriptionEntry, DataRedefinesEntry, DataRenamesEntry, DataConditionEntry, FunctionDeclarationEnd}

Compile the following program using "develop" branch and CFG analyzer provider to reproduce the error:

   IDENTIFICATION DIVISION.
   PROGRAM-ID. VARTYPEXT.
   DATA DIVISION.
   LINKAGE SECTION.
     EXEC SQL DECLARE tablename1 TABLE
     (
       num  DECIMAL(45) NOT NULL,
       str  VARCHAR(256) NOT NULL
     ) END-EXEC.

   END PROGRAM VARTYPEXT.
alvaro-vantis-pt commented 3 years ago

As defined in IBM formal documentation at https://www.ibm.com/support/knowledgecenter/en/SSEPEK_12.0.0/apsg/src/tpc/db2z_sqlstatementscobol.html there are several SQL Statements type that can be used in LINKAGE SECTION. ANTLR4 Parser used at Parse time accepts SQL statements in LINKAGE SECTION but CUP parser used at Semantic Check step doesn't.

We should expect that CUP Parser also accepts SQL Statements in LINKAGE SECTION.