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

Bruce Steers bsteers4 at gmail.com
Sun Oct 29 00:50:28 CEST 2023


On Sat, 28 Oct 2023 at 22:21, Benoît Minisini <
benoit.minisini at gambas-basic.org> wrote:

> Le 28/10/2023 à 22:54, Bruce Steers a écrit :
> >
> > here is my sh definition file....
> > https://gitlab.com/gambas/gambas/-/merge_requests/313/diffs
> > <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.
>
> What is the exact syntax for "#" comments? Is it at the start of the
> line only? Or anywhere until the end of the line? I don't think a space
> after is required to be a comment.
>

It is # anywhere in a line starts a comment just NOT if it is inside {curly
braces}
i changed
from #
to be...
from /#\s/

but it's a workaround as i do not know syntax for # if it's not inside { }


> I have no idea what i am doing with pcre
>
> You can read the quick pcre syntax reference on the wiki to get an idea.
>

I got some of the basics but struggling with more complex stuff

>
> > This needs people with pcre regex knowledge to examine and refine as
> > frankly i am out of my depth.
> >
>
> Good job anyway. It's a start. :-)
>

Thanks,
and thank you for the component. the concept is awesome, hopefully others
will make their own highlight files for various other formats and we could
have a nice collection to choose from somewhere online.
I may add a few more to my script editor :)


>
> Can you repost your file, as the indentation has been lost in the mail
> servers swamp?
>

i've attached and have submitted a self-deleting merge request
https://gitlab.com/gambas/gambas/-/merge_requests/313

like you say, it's a start, it works okay for now, for the most part, as
far as i can tell.
Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231028/478baafa/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sh.highlight.tar.gz
Type: application/gzip
Size: 715 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231028/478baafa/attachment.gz>


More information about the User mailing list