Page 1 of 1

Cobol comment syntax highlight

Posted: Wed Nov 20, 2013 8:39 am
by PeterV
Hi,

Currently we are evaluating Zeus as our future editor for writing Cobol (and Delta) programs. So far we have managed to define the Cobol and Delta language for Syntax highlighting. One problem we still have is comment recognition in 'free format' COBOL and ANSI Cobol.
For 'free format' COBOL a comment will start on the first column and in ANSI Cobol format it starts on column 7.
Until now we are not able to define the language recognize both.

The settings in Cobol.zki for comments are as follows:
LineComment01=0:*
CommentStart02=
CommentEnd02=
NestsComments02=No
LineComment02=7:*

These setting will result in correct syntax highlighting for ANSI Cobol format:
000022 INPUT-OUTPUT SECTION. 01000283
000023 FILE-CONTROL. 01000286
000024* ------------------------------------------------> SELECT 01000287
000025 SELECT IVP0001P ASSIGN TO "SFB_IVP0001P". 08000180
000026 DATA DIVISION. 01000303
000027 FILE SECTION. 01000305
000028* ------------------------------------------------> FD 01000306

But for the 'free format' COBOL syntax hihlighting only shows for lines having a "*" at colum 7:

/
********************************************************************************
* CALL_TPINITIALIZE
********************************************************************************
call_tpinitialize SECTION.
begin.

MOVE SPACES TO usrname IN tpinfdef-rec.

Is there a setting possible that both situations will have correct syntax highlighting?

Kind regards,
Peter
[/img]

Posted: Wed Nov 20, 2013 12:16 pm
by jussij
Hi Peter,
Is there a setting possible that both situations will have correct syntax highlighting?
I have been able to replicate the issue you are seeing and the issue is caused by the fact that both comment patterns are identical.

Unfortunately because of the way the comment parsing works I don't think there is a way to fix this :(

The best solution that I could suggest is defining the comments as follows:

Code: Select all

Line Comment #1
0:**

Line Comment #2
0:*
This is just tricking the comment parser by making the comment patterns slightly different ;)

Those settings will color this ANSI formatted comment correctly:

Code: Select all

000024* ------------------------------------------------> SELECT 01000287
000025 SELECT IVP0001P ASSIGN TO "SFB_IVP0001P". 08000180
000026 DATA DIVISION. 01000303
000027 FILE SECTION. 01000305
000028* ------------------------------------------------> FD 01000306
It will also color this free format comment correctly:

Code: Select all

********************************************************************************
** CALL_TPINITIALIZE
********************************************************************************
And also this free format comment:

Code: Select all

  
        ********************************************************************************
        ** CALL_TPINITIALIZE
        ********************************************************************************
But it will not correctly color this free format comment line:

Code: Select all

* CALL_TPINITIALIZE
Cheers Jussi

Posted: Wed Nov 20, 2013 12:25 pm
by PeterV
Hi Jussi,

Thanks for the quick answer.
Altough not a solution for all situations much better.

Peter