The wordfile
cobol.uew on page
User-submitted wordfiles for UltraEdit/UEStudio is updated with the improvements as described below. The wordfile
cobol_names.uew is additionally available in the
wordfiles repository on GitHub The two files are identical with exception of the first line. The user-submitted wordfile
cobol.uew as of 2024-04-30 had in the first line:
File Extensions = COB CBL CPY
File Names = COBLIB COBLIBRP
That is invalid. It is not really possible to use in one wordfile
File Extensions = and
File Names =. UltraEdit interprets everything after
File Extensions = as space separated list of file extensions up to the end of the line and everything after
File Names = as space separated list of file names up to the end of the line. So such a definition results in not only applying the COBOL syntax highlighting language as defined in this wordfile to the files
coblib,
coblibrp,
*.cob,
*.cbl,
*.cpy, but also to
*.file,
*.names,
*.=,
*.coblib and
*.coblibrp. Such files most likely never exist, but the definition is nevertheless invalid.
The help page with title
Syntax Highlighting in UltraEdit for Windows v2022.0.0.102 contains:
File Names/Extensions Considerations
The following items must be considered if using both File Names and File Extensions options in the same wordfile:
- Names including spaces may not be specified with the File Names option.
- The File Names option may not be used in conjunction with the File Extensions option.
- If a language is defined using the File Names option, and a different language within the same wordfile is specified using the File Extensions option and the definitions overlap, the language defined with the File Names option must have a lower language number, i.e.:
Example 1 - won't work:
/L6"XML General" XML_LANG Noquote ... File Extensions = XML XUL XSD XSL XSLT
/L12"XML Special" XML_LANG Noquote ... File Names = ThisIsJustAFile.xml
Example 2 - will work:
/L6"XML Special" XML_LANG Noquote ... File Names = ThisIsJustAFile.xml
/L12"XML General" XML_LANG Noquote ... File Extensions = XML XUL XSD XSL XSLT
I used the information provided by Tutorials Point
COBOL Tutorial to enhance the wordfile for COBOL. I have not read all COBOL tutorial pages carefully and have not used all examples to test the syntax highlighting and the function list enhancements. Therefore it is possible that something is not working correct, i.e. strings are missing in the
Function List view or there are strings listed which should not be in this list.
My goal on enhancing the wordfile was to get highlighted only strings which are valid in the file according to syntax rules of COBOL as much as possible and get listed in
Function List view only valid strings, i.e. their first character is within the columns 8 to 11. For that reason all regular expression strings begin with
^(?:[0-9]{6} {1,4}| {7,10}) which means:
^ ... find at beginning of a line
(?:...
|...
) either a string matched by the first
or the second expression defined in a
non-marking/non-capturing group
[0-9]{6} {1,4} ... with first expression searching exactly for six digits followed by one to four spaces and
{7,10} .. with second expression searching for seven to ten spaces.
Please let me know if this Perl regular expression part is too restrictive and let me know with examples the reason.
The COBOL wordfiles have following enhancements:
- The keyword Nocase is moved left after the language marker keyword as that is the typical position of this keyword in wordfiles. That makes no change on syntax highlighting.
- The Line Comment Valid Columns = definition is modified to allow only column 7 as valid column for an asterisk to be interpreted as the beginning of a line comment. Please let me know if this is too restrictive.
- The list of delimiters is reduced to those characters being allowed in a COBOL file and are not part of a word. The horizontal tab character is still not in the list. A horizontal tab does not belong to the list of allowed characters according to basic syntax page which is logic in my opinion as COBOL syntax is position dependent. For that reason no Perl regular expression search string contains anymore \t to match a horizontal tab character. If a horizontal tab is used at beginning of a line, the line is always ignored by all regular expressions.
- The function string definitions are for a hierarchical function list with the following groups:
- Author (on existing)
- Program identifier (on existing)
- Divisions (only the four possible)
- Sections (on existing) ... variable as the procedure division can have variable sections
- Procedures (on existing)
Note: It is not possible to limit the search for procedures to just the procedures division block. So I hope this expression works fine and does not produce too many false positives. The expression contains a negative look-ahead with an on OR expression to exclude three false positives I have seen already on testing the wordfile on examples copied from Tutorials Point COBOL tutorial pages. There can be other strings added to this OR expression inside the look-ahead expression. Please let me know them.
- The open/close fold strings are extended to offer also code folding of divisions, sections and multi-line loops.
- /Word Select Include = - is added to get interpreted the non-word character hyphen as word character on executing the command Select word like with double clicking on a word. I think the COBOL programmers will like that.
- The color groups have all names now which helps on configuring the colors and font styles for the syntax language COBOL in the Manage Themes dialog window.
- The color groups Operators, Brackets and Delimiters are added by me which could be very useful with appropriate color / font style settings.
I did not modify any word list. The words in the first five color groups were already perfect which means all sorted well, no duplicates and no invalid words.