Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected WORD "SD" parsing cobol program #175

Open
sergiosa61 opened this issue Mar 20, 2024 · 4 comments · May be fixed by #176
Open

Unexpected WORD "SD" parsing cobol program #175

sergiosa61 opened this issue Mar 20, 2024 · 4 comments · May be fixed by #176

Comments

@sergiosa61
Copy link

In trying to process a cobol program for our Oracle migration project, I get the following error.

--accepting rule at line 1388("SD")
Next token is token WORD (1.1-2546: SD)
Error: popping nterm sqlvariantstate_list (1.2204-2542: )
Stack now 0 1 6 44
Error: popping nterm $@3 (1.2204: )
Stack now 0 1 6
Error: popping token Begin of FILE SECTION (1.1-2203: )
Stack now 0 1
Error: popping nterm sqlstate_list (MU057R.PCO:1.1: )
Stack now 0
Cleanup: discarding lookahead token WORD (1.1-2546: SD)
Stack now 0
/dati/HDS/home/parsbt/SC3/WORK/MU057R.PCO(99): error: syntax error, unexpected WORD

These are the Cobol lines that generate the error.

000086 DATA DIVISION.
000087 FILE SECTION.
000088 FD  F-XSET
000089     LABEL RECORD STANDARD.
000090 01  A-XSET.
000091     03 RECXSET        PIC X(80).
000092     03 FILLER  REDEFINES  RECXSET.
000093      05 XSET-TIP       PIC X(04).
000094      05 XSET-NOMEINT   PIC X(10).
000095      05 XSET-NOMEEXT   PIC X(66).
000096      05  FILLER REDEFINES XSET-NOMEEXT.
000097       07 FILLER        PIC X(59).
000098       07 XSET-MAXREL   PIC X(07).
000099 SD  F-FSORT
000100     DATA RECORD A-FSORT  .
000101 01  A-FSORT.
000102       06 SORT-KEY                     PIC  9(007).
000103       06 SORT-CONTO                   PIC  9(015).

This is the syntax from the GnuCobol manual

GnuCOBOL 2.2 Final [7Sept2017] Programmer’s Guide
95
5.2.1. File/Sort-Description
�
File/Sort-Description Syntax
�
FD|SD file-name-1 [ IS EXTERNAL|GLOBAL ]
~~ ~~
~~~~~~~~ ~~~~~~
[ BLOCK CONTAINS [ integer-1 TO ] integer-2 CHARACTERS|RECORDS ]

The gixpp version

gixpp -V
gixpp - the ESQL preprocessor for Gix-IDE/GixSQL
Version: 1.0.20b
libgixpp version: 1.0.20b

The cobc version

>cobc -V
cobc (OpenCOBOL) 2.0.0
Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
Copyright (C) 2006-2012 Roger While
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Built     Nov 30 2023 11:35:35
Packaged  Feb 11 2012 12:36:31 UTC
C version "8.3.0"
GitMensch added a commit to GitMensch/gixsql that referenced this issue Mar 20, 2024
@GitMensch GitMensch linked a pull request Mar 20, 2024 that will close this issue
@GitMensch
Copy link
Contributor

I haven't checked the result (maybe it doesn't even build) - but can you please recheck after applying #176 ?

@sergiosa61
Copy link
Author

sergiosa61 commented Mar 20, 2024 via email

GitMensch added a commit to GitMensch/gixsql that referenced this issue Mar 20, 2024
@GitMensch
Copy link
Contributor

Adjusting the code, then make && sudo make install is enough. Nice to see that it compiles. But I've forgot to adjust the scanner (which creates the token for the parser).

It just occurred to me that the parser does not need to differ between FD and SD, so you can revert the change, then only adjust the scanner as follows:

--- a/libgixpp/gix_esql_scanner.ll
+++ b/libgixpp/gix_esql_scanner.ll
@@ -1245,7 +1245,7 @@ SUBSYSTEM "SQL"|"CICS"|"DLI"
 		return yy::gix_esql_parser::make_WORKINGEND(loc);
     }
 
-	"FD" {
+	("FD"|"SD") {
 		if (driver->data_division_section == DD_SECTION_FS) {
 			__yy_push_state(FD_STATE);
 		}

@sergiosa61
Copy link
Author

Hi, i revert the change to libgixpp/gix_esql_parser.yy.
I applied the new changes to libgixpp/gix_esql_scanner.ll

1206     "SCREEN"[ ]+"SECTION"[ ]*"." {
1207                 driver->startlineno = yylineno - 1;
1208                 driver->endlineno = yylineno - 1;
1209                 driver->host_reference_list->clear();
1210                 driver->res_host_reference_list->clear();
1211
1212                 driver->commandname = "WORKING_END";
1213                 driver->cursorname = "";
1214                 driver->sqlname = "";
1215                 driver->incfilename = "";
1216                 driver->data_division_section = DD_SECTION_INITIAL;
1217
1218                 driver->hostreferenceCount = 0;
1219                 driver->command_putother = 0;
1220                 driver->sql_list->clear();
1221
1222                 __yy_pop_state();
1223                 return yy::gix_esql_parser::make_WORKINGEND(loc);
1224     }
1225         ("FD"|"SD") {
1226                 if (driver->data_division_section == DD_SECTION_FS) {
1227                         __yy_push_state(FD_STATE);
1228                 }
1229                 return yy::gix_esql_parser::make_FD(loc);
1230         }
1231
1232     "PIC" |
1233     "PICTURE" {
1234                 __yy_push_state(PICTURE_STATE);
1235     }

gixpp still throws error

00086 : 000086 DATA DIVISION.
00087 : 000087 FILE SECTION.
00088 : 000088 FD  F-XSET
00089 : 000089     LABEL RECORD STANDARD.
00090 : 000090 01  A-XSET.
00091 : 000091     03 RECXSET        PIC X(80).
00092 : 000092     03 FILLER  REDEFINES  RECXSET.
00093 : 000093      05 XSET-TIP       PIC X(04).
00094 : 000094      05 XSET-NOMEINT   PIC X(10).
00095 : 000095      05 XSET-NOMEEXT   PIC X(66).
00096 : 000096      05  FILLER REDEFINES XSET-NOMEEXT.
00097 : 000097       07 FILLER        PIC X(59).
00098 : 000098       07 XSET-MAXREL   PIC X(07).
00099 : 000099 SD  F-FSORT
/dati/HDS/home/parsbt/SC3/WORK/MU057R.PCO(99): error: syntax error, unexpected WORD

I added the --parser-scanner-debug parameter

00099 : 000099 SD F-FSORT
--accepting rule at line 1396("
")
--accepting rule at line 1388("SD")
Next token is token WORD (1.1-2546: SD)
Error: popping nterm sqlvariantstate_list (1.2204-2542: )
Stack now 0 1 6 44
Error: popping nterm $@3 (1.2204: )
Stack now 0 1 6
Error: popping token Begin of FILE SECTION (1.1-2203: )
Stack now 0 1
Error: popping nterm sqlstate_list (MU057R.PCO:1.1: )
Stack now 0
Cleanup: discarding lookahead token WORD (1.1-2546: SD)
Stack now 0
/dati/HDS/home/parsbt/SC3/WORK/MU057R.PCO(99): error: syntax error, unexpected WORD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants