IBM / zopeneditor-about

IBM Z Open Editor: File issues here!
https://ibm.github.io/zopeneditor-about
Apache License 2.0
47 stars 25 forks source link

COBOL - Textmate and Cobol Language Server on "replacing" term in copy clause when last term of the line #346

Closed FALLAI-Denis closed 1 year ago

FALLAI-Denis commented 1 year ago

Development environment used

Problem Description

Textmate error

The coloring of the term "replacing" in the "copy" directive depends on the content of the rest of the line:

COBOL Language Server error

If a floating comment is placed after the term "replacing" it is considered to be COBOL code.

Observed behavior

image

FALLAI-Denis commented 1 year ago

Related issue: #248

FALLAI-Denis commented 1 year ago

Hi,

For the textmate issue, I think the problem is here, and it's not just about the replacing keyword:

    {
      "match": "(?<![-_])(?i:...|replacing|...)(?=\\s|\\.|,)",
      "name": "keyword.identifers.cobol"
    },

the regular expression used expects a continuation after the keyword: a space, a point, or a comma.

It would also be necessary to provide the sequence end of line $. Or maybe just indicate a word separator\b.

Test with end-of-line:

    {
      "match": "(?<![-_])(?i:...|replacing|...)(?=\\s|\\.|,|$)",
      "name": "keyword.identifers.cobol"
    },

image

This problem seems to be generalized in the textmate grammar because there are many expressions of the form (?=\\s|\\.) which do not provide for the physical end of line.

FALLAI-Denis commented 1 year ago

Hi,

Regarding regular expressions used to isolate words in a COBOL sentence, I suggest using the following pattern:

(?<![\-])\b(?i:KEYWORD1|KEYWORD2|...|KEYWORDn)\b(?![\-])

phaumer commented 1 year ago

Fixed in Z Open Editor v3.2.0