vmssoftware / vms-ide

MIT License
13 stars 3 forks source link

FR: support of ANSI format #8

Open GitMensch opened 3 years ago

GitMensch commented 3 years ago

The following source shows the issue

       IDENTIFICATION DIVISION.
       PROGRAM-ID. testprog.
       AUTHOR. tester.
       DATA DIVISION.

DATA DIVISION is highlighted as "still comment". Something "breaks" the "end on DATA DIVISION" part.

sample

vorfol commented 3 years ago

COBOL highlighting is implemented for terminal format only.

The HP COBOL terminal format shortens program preparation time and
reduces storage space for source programs. This format eliminates the sequence
number and identification areas. It also combines the indicator area with Area A.
Except for the differences described in this section, the rules for ANSI format also
apply to terminal-format source programs.
In terminal format, the compiler recognizes the following valid indicator area
characters in the first character position:
( - ) hyphen
( * ) asterisk
( / ) slash
The compiler also recognizes the following conditional compilation line characters
as valid indicator area characters in the first and second character positions:
(\x) backslash and x
where x can be any uppercase or lowercase alphabetic character.
Area A then begins in character position 2 (or 3 if using \x). Otherwise, Area A
begins in the first character position.
Area B begins four character positions to the right of the beginning of Area A. It
ends when the compiler detects a carriage return, or at Margin R.
The maximum length of a terminal-format source line is 256 characters. The
compiler’s tab stops are immediately to the right of Margin B, and every eight
character positions to the right, until the end of the line.
GitMensch commented 3 years ago

Is it possible to add ANSI format, too? It seems that would be nearly a copy and paste from vms-cobol to a new vms-cobol-ansi.

vorfol commented 3 years ago

It is really hard to implement ANSI format. vms-cobol.tmLanguage.json

GitMensch commented 3 years ago

I'm not sure that I understand. The ansi version would be the noansi one, just replacing the conditionals by a single "D" and "somewhere" adjust the column 1 to column 7 and 2 to 8, wouldn't it?

vorfol commented 3 years ago

The TextMate language does not work with columns, but only with a limited set of regular expressions. https://macromates.com/manual/en/language_grammars

GitMensch commented 3 years ago

Hm, checking that file actually shows that line numbers and "normal" comment lines, which would only work for ANSI format, are also included. Maybe vms-cobol-ansi would actually only be about:

     "conditional": {
       "name": "cobol.conditional",
       "match": "(?i)^......D",
       "captures": {
         "0": {
           "name": "markup.bold"
         },
         "1": {
           "name": "comment.line"
         }
       }
     },

plus wherever the plugin handles the areas (which wouldn't be the syntax highlighting but a parser) adjust for the columns?