Thanks for figuring out how put the spec all in one tab to make the test easier!
When I paste in this Class as would be in an INC file:
ConstantClass CLASS,TYPE,MODULE('ABUTIL.CLW'),LINK('ABUTIL.CLW',_ABCLinkMode_),DLL(_ABCDllMode_)
CharPnt LONG,PRIVATE
Next PROCEDURE(FILE F)
END
The 2nd error 2:65 missing ')' at ',' wants Parens () after “Class” and not just a comma e.g. CLASS,TYPE.
The fix is to make the (fieldRef) optional with ()?
Before : ID CLASSKW LPAREN fieldRef? RPAREN classAttrList? lineEnd
Fixed : ID CLASSKW (LPAREN fieldRef? RPAREN)? classAttrList? lineEnd
After fixing the above it did not like the ,_ABCLinkMode_ in
LINK('ABUTIL.CLW',_ABCLinkMode_)
In classAttr there’s the LINK line
| LINKKW LPAREN expr? RPAREN
that does not allow a comma and second attribute ('file',_abc_).
It worked to add an optional “, ID” as
| LINKKW LPAREN expr? (COMMA ID)? RPAREN
Edit:
Link can have a number Link(,1) so change ID to expr?
| LINKKW LPAREN expr? (COMMA expr?)? RPAREN
After fixing LINK(,_id_) above then the error 4:18 no viable alternative at input 'Next PROCEDURE'
on the line Next PROCEDURE(FILE F)
I think Mark pointed out there is nothing to allow the format starting in column 1 of Name Procedure(parms).
The 1st error 1:0 missing 'PROGRAM' at 'ConstantClass'
makes me think the spec always wants “PROGRAM” first, but you can have a Class .INC / .CLW file that does not. Or a Member MODULE, or Equates, or code snippet.
To fix maybe add ? after programHeader to make it 1 or 0 times
Yes! No more error after adding ? so : programHeader?
program
: programHeader? //<--- Add ? on End -----------
lineEnd* // allow blank lines after PROGRAM
mapSection?
(lineEnd | declarationSection)* // allow interleaved blank lines and declarations
codeSection
lineEnd* // allow trailing blank lines
EOF
;
programHeader
: PROGRAM
;
Re mapSection? there can be multiple MAP’s so change ? to * = mapSection*
Those can be mixed with Data declartions so maybe (group)* MAP and Data:
program
: programHeader? //<--- Add ? on End so PROGRAM is optional -------
lineEnd* // allow blank lines after PROGRAM
( // Group (MAP + DATA)* to allow multiple MAPs mixed with Data
mapSection* //change ? to * to allow multiple MAPs
(lineEnd | declarationSection)* // allow interleaved blank lines and declarations
)* // Group (MAP + DATA)*
codeSection
FYI in the very first post at the bottom I added a few syntax rules about ANTLR.
