Thank you for the good example file explaining also REBOL syntax. That was a great help.
I redefined first the first line just to have the standard order and the file extensions listed in alphabetical order.
Next I removed all color and font style settings using the macro
SettingsDelAll from
the ultimate syntax highlighting tools package because of color and font style settings for a syntax highlighting language are defined since UltraEdit for Windows in theme settings and no longer read from wordfile.
Then I executed the macros
SortLanguage,
TestForDuplicate and
TestForInvalid also from the ultimate syntax highlighting tools package The first macro is enhanced by me in the meantime locally for sorting also the delimiters with special algorithm for space and horizontal tab although the delimiters can be specified in any order.
TestForDuplicate found
pi and
zero being defined in
/C5 and
/C9. So I removed them from
/C9.
TestForInvalid found
// and
<> which I also removed because
/<> are word delimiters and so these three characters are highlighted in any case with color group 6 which I renamed from
Ops to
Operators.
/C9 was now an empty group and I missed syntax highlighting for
():[]{}. So I renamed color group 9 to
Brackets/colon and added those characters to this color group.
A syntax highlighting language can be defined with no string highlighting at all using keyword
Noquote in first line or with single line or multi-line string highlighting with one or two characters marking begin and end of a string.
DisableMLS in first line disables multi-line string highlighting while the default
EnableMLS enables explicitly multi-line string highlighting. On language having two characters for strings like JavaScript with
" and with
' it is possible to specify one of these two string starting/ending characters like a word in a color group to highlight those strings with the color assigned to this color group and the other strings with the color assigned for strings, i.e.
"double quoted string" versus
'single quoted string'.
However, it is not possible to specify that a string starts with character X and ends with character Y. For that reason
{ and
} are defined as alternate block comments which is by default always a multi-line highlighting. Of course an alternate block comment can be folded which means here on
{ and
} being used for a multi-line string that this multi-line string can be also folded. As REBOL interprets
{ and
} also as multi-line comment depending on what is before
{ makes the alternate block comment definition even right for some cases. It is of course impossible at the moment with UltraEdit for Windows v25.20 that UltraEdit recognizes in which context
{ and
} is used and so highlights everything between those two characters always with the color defined for alternate block comments.
Code folding
It is not necessary to define open/close fold strings like open/close brace strings in matching pairs. There can be more open than close fold strings and vice versa. The open/close fold strings can be specified in any order. It is also possible to specify a string as open
and as close fold string. Open/close fold strings can contain also word delimiters, even one or more spaces and tabs.
So I suggest following for coding folding:
/Open Fold Strings = ": function"
/Close Fold Strings = ": function"
Code folding is from one function definition line to next function definition line. The last function in file cannot be folded as there is no more
: function.
A function with name and colon on line X and the keyword
function on next line like function
f-HIDDEN in example file is ignored by this definition of open/close fold strings. And of course a tab instead of a space or two or more spaces instead of a single space results also in ignoring the function for code folding. So this definition makes sense only when not using all freedoms of REBOL syntax and use strictly
: function on the line after function name.
More flexible is:
/Open Fold Strings = "function"
/Close Fold Strings = "function"
Here is just the keyword
function used to define where to start and where to end code folding. So it does not matter anymore where is the colon and how much horizontal or vertical whitespace characters are between colon and keyword
function. But if somebody uses the string
function with a different meaning in a REBOL file, the code folding would be wrong. However, I suppose that using the string
function for something else is in general a bad idea even if it would be possible because of REBOL interpreter takes context into account.
This is the variant used in rebol.uew inside the attached ZIP file.
Also possible would be using:
/Open Fold Strings = ":"
/Close Fold Strings = ":"
This results in offering code folding not only for functions, but also for string and block assignments, i.e. everything from one block/function/string assignment to next block/function/string can be folded. I honestly liked this very simple one most as I tested the various open/close folding strings. Why not using code folding for folding also strings and blocks?
On all three variations of open/close fold strings definitions it is additionally possible to add
"[
" as open and
"]
" as close fold strings to be able to fold also everything between square brackets for a two level code folding.
Function list
First, there are characters escaped in UltraEdit regular expression strings with
^ which don't need to be escaped. So I removed the unnecessary
^ to get the expressions better readable.
Second, I could see a space in all character class definitions between
a-z and
0-9. I don't think this is right and removed this space from all character class definitions.
Third, there were too much
TGFindBStart and
TGFindBEnd. The most outer groups should not have them. So I removed those lines where they were wrong.
Fourth, the strings assigned to
TGFindBStart and
TGFindBEnd are interpreted also as regular expression search strings which means
[ and
] must be escaped to be interpreted as literal characters in Perl syntax with
\ and in UltraEdit syntax with
^.
Fifth, there are many similarities on the used UltraEdit regular expression search strings and so I decided to switch to more powerful Perl regular expression to reduce the number of regular expression search strings which results in faster processing a file for strings to display in function list view.
The last problem was your wish to show a hierarchical object/method definition also hierarchical in function list view. REBOL supports obviously a recursive definition of objects inside objects with each object having its own methods. The function list feature of UltraEdit does not support recursion. That would require parsing the file like REBOL interpreter obviously does with real language parsing knowledge instead of using regular expression searches on file without language parsing knowledge.
I have nevertheless tried to fulfill your wish for two levels by taking indentation level into account. I assumed either one horizontal tab or four spaces are used for indentation by one level. This indentation rule defined by me is not valid for
fobj2: function which is indented by three tabs instead of two tabs which is the reason for
fobj2 method not shown in function list for
Subobject obj2.
An object and a function on first level must be defined at beginning of a line without any leading tabs/spaces. A subobject or a method being part of an object must be on a line with either one tab or four spaces. And a method of a subobject must be on a line with two tabs or 8 spaces.
Something better is not possible because of recursion is not supported for searching for strings to list hierarchical in function list view.
It is the first time that I see a language which uses recursion in source code file itself for definition of hierarchical objects with their methods.
In case of a hierarchical function list for hierarchical objects with their methods is not so important for you as added to attached wordfile, here are the function strings for a non-hierarchical display of objects and their methods in function list view whereby
fobj2 is listed twice, once for object
obj1 which of course is not right and once more for
obj2 which is right. I don't have an idea how to exclude
fobj2 in methods list of
obj1 without taking indentation into account.
Code: Select all
/TGBegin "Does"
/TGFindStr = "^(?:%|[\t ]*do)[\t ]+(?:%"?|to-file[!\s]+|to-rebol-file["\s]+)([0-9a-z!&'*+\-.=?_~]+)"
/TGEnd
/TGBegin "Dynamic Includes"
/TGFindStr = "^[\t ]*include[ /]+([0-9a-z!%&'*+\-./=?_~]+)"
/TGEnd
/TGBegin "Static Includes"
/TGFindStr = "^[\t ]*#include[ \-]+([0-9a-z!%&'*+\-./=?_~]+)"
/TGEnd
/TGBegin "Objects"
/TGFindStr = "^[\t ]*([0-9a-z!&'*+\-.=?_~]+):\s+(?:construct\>|context\>|make object!)"
/TGFindStr = "^set[\t ]+'([0-9a-z!&'*+\-.=?_~]+)\s+(?:construct\>|context\>|func\>|does\>|make object!)"
/TGBegin "Methods"
/TGFindStr = "^[\t ]*([0-9a-z!&'*+\-.=?_~]+):\s+(?:function|func|does)\>"
/TGFindBStart = "\["
/TGFindBEnd = "\]"
/TGEnd
/TGEnd
/TGBegin "Functions"
/TGFindStr = "^[\t ]*([0-9a-z!&'*+\-.=?_~]+):\s+(?:function\>|func\>|does\>|make function!|has\>)"
/TGFindStr = "^set[\t ]+'([0-9a-z!&'*+\-.=?_~]+\s+(?:{function\>|make function!|\has\>)"
/TGEnd
It could be possible to use just one Perl regular expression search string for objects and for functions, but I would need examples for objects and methods defined with
set ' at beginning of a line to define and validate the regular expression and avoid false positive matches. Well, false positive matches could occur already with the reduced number of search strings because of they find most likely some very special constructs which are not valid for REBOL interpreter. But I think a faster search for strings to list in function list is for REBOL code writers more important than using multiple regular expression search strings to avoid false positive matches on constructs which a REBOL code writer never uses in REBOL code files and so are only theoretically but not practically relevant.
Please let me know if you detect an issue on which I could help to fix it or if you have more REBOL syntax highlighting wishes on which I could help to implement them.