I am using ANTLR for writing grammar for ZOS JCL language. There can be 4 types of lines:
- Type 1: All statements start with a '//' in the first 2 characters of the line
- Type 2: Comments start with a '//*'
- Type 3: lines starting with '/*'
- Type 4: lines starting with any other pattern other than types 1, 2 and 3
Given below is the segment from my grammar file :
dd4: JCLBEGIN ddname DDWORD '*' inlinerec INLINESTMTEND?;
inlinerec: (INLINEDATA)+ ;
fragment INLINEDATA: (~[\r\n])*;
.
.
.
DDWORD: 'DD';
.
.
JCLBEGIN: '//' ;
COMMENTBEGIN: '//*' ;
INLINESTMTEND: '/*' ;
.
.
WS : [\r\n] -> channel(HIDDEN);
when using AntlrWorks to run this grammar, the parser rule inlinerec
is matched correctly but I get the following error:
line 24:0 mismatched input 'SORT' expecting INLINEDATA
and the section of my code where the error occurs is:
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND
/*
How can I resolve this error ?