ScintillaOrg / lexilla

A library of language lexers for use with Scintilla
https://www.scintilla.org/Lexilla.html
Other
163 stars 59 forks source link

COBOL keywords starting with V are not styled #230

Closed mpheath closed 2 months ago

mpheath commented 3 months ago

Keywords like VARIANCE and VARYING are not identified as keywords.

The issue appears to be code testing for a numeric literal that can contain the letter v

https://github.com/ScintillaOrg/lexilla/blob/a86f23628da5f7b6dcaf190ae8a73efb331fa828/lexers/LexCOBOL.cxx#L99

which causes keyword identication in the else code to not occur for keywords starting with the letter v .

mpheath commented 3 months ago

Fix with #229 string style fix included. Please commit after #229.

230.zip

nyamatongwe commented 3 months ago

I think this is about supporting (a subset of) picture clauses which use 'V' to indicate an assumed decimal position like PI PICTURE 9V99999 VALUE 3.14159..

mpheath commented 3 months ago

I think this is about supporting (a subset of) picture clauses which use 'V' to indicate an assumed decimal position like PI PICTURE 9V99999 VALUE 3.14159..

So true, though it does not allow keywords starting with v . The code sees v and considers it a numeric literal for testing. Even if it fails testing as numeric literal and sets it to style identifier, it still misses the inlist test to test for keyword. This fix gives it a second chance to be recognized as a keyword if it failed to be numeric literal.

Found an example with a numeric literal with V in it :

       >>SOURCE FORMAT FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. tutorial21.
DATA DIVISION.
WORKING-STORAGE SECTION.
*> Most programming languages use floating point
*> calculations which can introduce errors.
*> COBOL uses fixed point decimal arithmetic
*> and allows you to define how you will round.
01 Price PIC 9(4)V99.
01 TaxRate PIC V999 VALUE .075.
01 FullPrice PIC 9(4)V99.

PROCEDURE DIVISION.
DISPLAY "Enter the Price : " WITH NO ADVANCING
ACCEPT Price
COMPUTE FullPrice ROUNDED = Price + (Price * TaxRate)
DISPLAY "Price + Tax : " FullPrice.
VARYING *> keyword?
STOP RUN.

I inserted VARYING *> keyword? before STOP RUN. . Before fix, VARYING not seen as keyword. After fix, see as keyword.