[Gambas-user] New highlighting component (episode 2)

Bruce Steers bsteers4 at gmail.com
Sat Oct 28 22:54:51 CEST 2023


On Sat, 28 Oct 2023 at 13:19, Bruce Steers <bsteers4 at gmail.com> wrote:

>
>
> On Sat, 28 Oct 2023 at 09:07, Benoît Minisini <
> benoit.minisini at gambas-basic.org> wrote:
>
>> Hi,
>>
>> The old 'gb.eval.highlight' component has just been replaced by
>> 'gb.highlight' in master, inside the 'gb.form.editor' component and in
>> the IDE itself.
>>
>> As this is fresh code, you may encounter unexpected problems or crashes,
>> so be careful, and report them as usual.
>>
>> - Only Gambas highlighting returns procedure limits at the moment.
>>
>> - The 'sh' highlighting has not been written yet. I waiting for Bruce
>> Steers here :-).
>>
>
> I think i will have to fall on my sword here Ben.
> gambas i understand , regex I am clueless to, almost zero experience.
> I made a commit but i do not like it. it's buggy (see merge comments)
>
> And knowing so little about regex syntax i do not know if it's buggy
> because of me or not?
>
> Respects
> BruceS
>

here is my sh definition file....
https://gitlab.com/gambas/gambas/-/merge_requests/313/diffs

---------------------------------------
comment:
from #
number:
match /[+-]?[0-9]+(\.[0-9]+)?([Ee][+-]?[0-9]+)?/
match /0x[0-9a-fA-F]+/
string:
from " to "
from ' to '
escape:
match /\\[fnrtv0'"\\]/
match /\\c[A-Za-z]/
match /\\x[0-9a-fA-F]{2}/
match /\\u[0-9a-fA-F]{4}/
match /\\u{[0-9a-fA-F]+}/
keyword:
word function do else test for to in fi if elif then return exit while
until done break continue select case esac
operator:
symbol { } $ # [ ] -gt -lt -ge -ne -le -eq <<< . + << = >> == - ~ += ( , !=
* -= &= ;; ) < % & ]; @ ! ; > | ? ^ : <= / `
function:
keyword echo read cd which rm cp mv rmdir cat grep awk tr sed sleep clear
sudo su source eval export time date pwd set unset chown chmod exec alias
unalias bg bind builtin caller command compgen complete compopt declare
dirs disown enable fc fg getopts hash help history jobs kill let local
logout mapfile popd printf pushd readarray readonly shift shopt suspend
test times trap type typeset ulimit umask wait
----------------------------------------------
i simply copied the numerical and string patterns from other files.

problems...
the hash # for comments gets registered at ANY # char even one in a
statement.
i wanted to set it to "# " (with a space) but do not know how.
I have no idea what i am doing with pcre

This needs people with pcre regex knowledge to examine and refine as
frankly i am out of my depth.

I marked it as ready to merge Ben
it works but it's not perfect.
you can see what i mean about the # char needing a space to define comments
in the attached test pic.

i think i've done all i can with my lack of regex know how.

Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231028/3624992e/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Untitled.jpg
Type: image/jpeg
Size: 119988 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231028/3624992e/attachment-0001.jpg>


More information about the User mailing list