Re: Zig parsers for Global

Simon D <[email protected]> Tue, 5 Sep 2023 10:25:44 +0100
Newsgroups gmane.comp.gnu.global.bugs
Message-ID <CA+i7qFhBjHCPC0ur0AuNLd_+O_HNYRAzp-3suL3y2E1E2Vc3+Q@mail.gmail.com>
--000000000000835f7d0604993820
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

> Other parsers don't treat variable definitions to be definitions. So I
> think you should adjust accordingly.

Ok

> No, that's not what I meant. I'm talking about the links on the source
code.

Does Japanese use character byte values >=3D 0x80,
as I removed those values from my flex (zig.l) files.

In yours: ALPHA [a-zA-Z_\x80-\xff]
ALPHANUM [a-zA-Z0-9_\x80-\xff]
In mine: ALPHA [a-zA-Z_]
ALPHANUM [a-zA-Z0-9_]

Sounds like that could be the problem, sorry.

Simon


On Tue, 5 Sept 2023, 08:41 Shigio YAMAGUCHI, <[email protected]> wrote:

> Hi,
> > From what I gathered about the '|x|' statement in Zig, it is like an
> index variable,
> > like the first 'y' in the C/C++ code 'for(int y =3D 0; y < 4;)', that's
> why I made it
> > a definition; can change it if you like.
>
> Other parsers don't treat variable definitions to be definitions. So I
> think you should
> adjust accordingly. Your parser also seems to treat normal variables
> as other symbols.
>
> > > o Definition/reference links are not displayed at all.
> >
> > It is just the names beginning with a '@' that are not displayed in the
> htags main
> > 'Definitions' (index), I thought.
>
> No, that's not what I meant. I'm talking about the links on the source
> code.
> Definition/reference links in the source code were not displayed at all
> at least as far as I've processed zig source code
> (https://github.com/ziglang/zig).
> The coloring process is complete (comment, string, reserved word and
> etc) though.
>
> Regards,
> Shigio
>
> On Tue, Sep 5, 2023 at 3:07=E2=80=AFPM Simon D <[email protected]=
> wrote:
> >
> > Hi,
> >
> > > 150    for (log_scopes.items) |log_scope| {              <=3D=3D defi=
nition
> >
> > From what I gathered about the '|x|' statement in Zig, it is like an
> index variable, like the first 'y' in the C/C++ code 'for(int y =3D 0; y =
<
> 4;)', that's why I made it a definition; can change it if you like.
> > Then on the next line 'if (mem.eql(u8, log_scope, ...' , it would be a
> reference.
> >
> > > o Definition/reference links are not displayed at all.
> >
> > It is just the names beginning with a '@' that are not displayed in the
> htags main 'Definitions' (index), I thought.
> >
> > > Does this mean it's still a work in progress?
> >
> > Yes
> >
> > > Finally, thanks for all the hard work!
> >
> > Thanks
> >
> > Simon
> >
> >
> > On Tue, 5 Sept 2023, 05:17 Shigio YAMAGUCHI, <[email protected]> wrote:
> >>
> >> Hi
> >> Please let me make a few comments.
> >>
> >> 1. Gtags
> >>
> >> In the following source code, variable 'log_scope' seems to be
> >> treated as a definition(-d) or a reference(-r).
> >>
> >> [src/main.zig from https://github.com/ziglang/zig]
> >> 150    for (log_scopes.items) |log_scope| {              <=3D=3D defin=
ition
> >> 151        if (mem.eql(u8, log_scope, scope_name)) <=3D=3D reference
> >> 152            break;
> >> 153        } else return;
> >>
> >> $ global -x log_scope
> >> ...
> >> log_scope         150 src/main.zig             for (log_scopes.items)
> >> |log_scope| {
> >> ...
> >> $ global -x log_scope -r
> >> ...
> >> log_scope         151 src/main.zig                 if (mem.eql(u8,
> >> log_scope, scope_name))
> >> ...
> >>
> >> But wouldn't it be appropriate to treat it as an other symbol(-s)?
> >> Because other places seem to treat variables only as other symbols(-s)=
.
> >>
> >> 2. Htags
> >>
> >> o Function guides(--func-header) are only at the beginning and end of
> the file.
> >> o Definition/reference links are not displayed at all.
> >>
> >> Does this mean it's still a work in progress?
> >>
> >> And one more thing.
> >>
> >> > Also changed HTML_quoting() in 'htags/src2html.c' to help spot and
> make safe
> >> > funny characters in source files, like the ones in
> >> > 'libdb/sqlite3.c' (0xB1 and 0xC4); but this change is not really
> necessary.
> >>
> >> I would appreciate it if you could focus on one theme for each patch.
> >>
> >> Finally, thanks for all the hard work!
> >>
> >> Regards,
> >> Shigio
> >>
> >> On Sat, Sep 2, 2023 at 9:44=E2=80=AFAM Simon D <si.octal.nibble@gmail.=
com>
> wrote:
> >> >
> >> >
> >> > Hi Shigio and other Global developers,
> >> >
> >> > I have created Zig parsers for Gtags and Htags version 6.6.10.
> >> >
> >> > I don't program in Zig, but have tested it on a number of Zig source
> files.
> >> > Zig is an Open Source language, so you can download its source files=
.
> >> >
> >> > I did modify makeincludeindex() to include the @import() functions o=
f
> Zig, but
> >> > it didn't seem to make any difference, so I removed the code.
> >> > The @import functions (like '#include' in C) are made into HTML link=
s
> with the
> >> > htags parser, and they work.
> >> >
> >> > Had to change compress() for names beginning with '@' in them.
> >> > I don't think you need to change the version number of the format of
> the
> >> > Global databases. I have left the '@' character in as part of the
> name, like in
> >> > the built-in function '@ptrToInt' for example, as this is what the
> text editor
> >> > Kate also does when syntax hilighting Zig code. Thus it gets saved
> into the
> >> > databases as '@ptrToInt'.
> >> > But the HTML index htags generates, doesn't include an entry for nam=
es
> >> > beginning with '@' yet, maybe one day.
> >> >
> >> > Also changed HTML_quoting() in 'htags/src2html.c' to help spot and
> make safe
> >> > funny characters in source files, like the ones in
> >> > 'libdb/sqlite3.c' (0xB1 and 0xC4); but this change is not really
> necessary.
> >> >
> >> > I thought I had gone wrong with the Zig function pointers, like 'xxx=
:
> fn ()',
> >> > that are in 'struct' statements, as some of them don't get the
> guide/icons with
> >> > them, but these function pointers are not function definitions.
> >> > I will fix this in the next update of the Zig parsers.
> >> >
> >> > I think I can add code to parse Zig function calls, so this could be
> a future
> >> > enhancement.
> >> >
> >> > I have also fixed some minor text messages, code and doxygen code,
> hope they
> >> > are ok.
> >> >
> >> > Hope these parsers are useful for Global.
> >> >
> >> > (Feature request: a Language Server Protocol [LSP] interface).
> >> >
> >> > I will be sending another email soon, more bugs, mainly involving
> strcmp().
> >> > And one bug found in __bt_first() 'libdb/bt_seq.c' by CppCheck:
> >> >
> >> > 'if ((h =3D xxx()) =3D=3D NULL) { if (h->pgno =3D=3D save.page->pgno=
) ....}'
> >> >
> >> >
> >> >
> >> > Simon Dommett
> >> >
> >>
> >>
> >> --
> >> Shigio YAMAGUCHI <[email protected]>
> >> PGP fingerprint:
> >> 26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB
>
>
>
> --
> Shigio YAMAGUCHI <[email protected]>
> PGP fingerprint:
> 26F6 31B4 3D62 4A92 7E6F  1C33 969C 3BE3 89DD A6EB
>

--000000000000835f7d0604993820
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"auto"><div dir=3D"auto">&gt; Other parsers don&#39;t treat vari=
able definitions to be definitions. So I<br>&gt; think you should adjust ac=
cordingly.<br></div><div dir=3D"auto"><br></div><div dir=3D"auto">Ok</div><=
div dir=3D"auto"><br></div><div dir=3D"auto">&gt; No, that&#39;s not what I=
 meant. I&#39;m talking about the links on the source code.<br></div><div d=
ir=3D"auto"><br></div><div>Does Japanese use character byte values &gt;=3D =
0x80,<div dir=3D"auto">as I removed those values from my flex (zig.l) files=
.</div><div dir=3D"auto"><br></div><div dir=3D"auto"><span style=3D"font-fa=
mily:monospace;font-size:medium;white-space:pre-wrap;background-color:rgb(2=
55,255,255)">In yours:  ALPHA        [a-zA-Z_\x80-\xff]</span></div><div di=
r=3D"auto"><font face=3D"monospace" size=3D"3"><span style=3D"white-space-c=
ollapse: preserve;">           ALPHANUM     [a-zA-Z0-9_\x80-\xff]</span></f=
ont></div><div dir=3D"auto"><span style=3D"font-family:monospace;font-size:=
medium;white-space:pre-wrap;background-color:rgb(255,255,255)">In mine:   <=
/span><span style=3D"background-color:rgb(255,255,255);font-family:monospac=
e;font-size:medium;white-space:pre-wrap">ALPHA        [a-zA-Z_]</span></div=
><div dir=3D"auto"><span style=3D"background-color:rgb(255,255,255)"><font =
face=3D"monospace" size=3D"3"><span style=3D"white-space-collapse: preserve=
;">           ALPHANUM     [a-zA-Z0-9_]</span></font></span></div><div dir=
=3D"auto"><div dir=3D"auto"><br></div></div>Sounds like that could be the p=
roblem, sorry.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Simon</di=
v><div dir=3D"auto"><br><br><div class=3D"gmail_quote" dir=3D"auto"><div di=
r=3D"ltr" class=3D"gmail_attr">On Tue, 5 Sept 2023, 08:41 Shigio YAMAGUCHI,=
 &lt;<a href=3D"mailto:[email protected]" rel=3D"noreferrer noreferrer" target=
=3D"_blank">[email protected]</a>&gt; wrote:<br></div><blockquote class=3D"gma=
il_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-lef=
t:1ex">Hi,<br>
&gt; From what I gathered about the &#39;|x|&#39; statement in Zig, it is l=
ike an index variable,<br>
&gt; like the first &#39;y&#39; in the C/C++ code &#39;for(int y =3D 0; y &=
lt; 4;)&#39;, that&#39;s why I made it<br>
&gt; a definition; can change it if you like.<br>
<br>
Other parsers don&#39;t treat variable definitions to be definitions. So I<=
br>
think you should<br>
adjust accordingly. Your parser also seems to treat normal variables<br>
as other symbols.<br>
<br>
&gt; &gt; o Definition/reference links are not displayed at all.<br>
&gt;<br>
&gt; It is just the names beginning with a &#39;@&#39; that are not display=
ed in the htags main<br>
&gt; &#39;Definitions&#39; (index), I thought.<br>
<br>
No, that&#39;s not what I meant. I&#39;m talking about the links on the sou=
rce code.<br>
Definition/reference links in the source code were not displayed at all<br>
at least as far as I&#39;ve processed zig source code<br>
(<a href=3D"https://github.com/ziglang/zig" rel=3D"noreferrer noreferrer no=
referrer noreferrer" target=3D"_blank">https://github.com/ziglang/zig</a>).=
<br>
The coloring process is complete (comment, string, reserved word and<br>
etc) though.<br>
<br>
Regards,<br>
Shigio<br>
<br>
On Tue, Sep 5, 2023 at 3:07=E2=80=AFPM Simon D &lt;<a href=3D"mailto:si.oct=
[email protected]" rel=3D"noreferrer noreferrer noreferrer" target=3D"_bl=
ank">[email protected]</a>&gt; wrote:<br>
&gt;<br>
&gt; Hi,<br>
&gt;<br>
&gt; &gt; 150=C2=A0 =C2=A0 for (log_scopes.items) |log_scope| {=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;=3D=3D definition<br>
&gt;<br>
&gt; From what I gathered about the &#39;|x|&#39; statement in Zig, it is l=
ike an index variable, like the first &#39;y&#39; in the C/C++ code &#39;fo=
r(int y =3D 0; y &lt; 4;)&#39;, that&#39;s why I made it a definition; can =
change it if you like.<br>
&gt; Then on the next line &#39;if (mem.eql(u8, log_scope, ...&#39; , it wo=
uld be a reference.<br>
&gt;<br>
&gt; &gt; o Definition/reference links are not displayed at all.<br>
&gt;<br>
&gt; It is just the names beginning with a &#39;@&#39; that are not display=
ed in the htags main &#39;Definitions&#39; (index), I thought.<br>
&gt;<br>
&gt; &gt; Does this mean it&#39;s still a work in progress?<br>
&gt;<br>
&gt; Yes<br>
&gt;<br>
&gt; &gt; Finally, thanks for all the hard work!<br>
&gt;<br>
&gt; Thanks<br>
&gt;<br>
&gt; Simon<br>
&gt;<br>
&gt;<br>
&gt; On Tue, 5 Sept 2023, 05:17 Shigio YAMAGUCHI, &lt;<a href=3D"mailto:shi=
[email protected]" rel=3D"noreferrer noreferrer noreferrer" target=3D"_blank">shi=
[email protected]</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi<br>
&gt;&gt; Please let me make a few comments.<br>
&gt;&gt;<br>
&gt;&gt; 1. Gtags<br>
&gt;&gt;<br>
&gt;&gt; In the following source code, variable &#39;log_scope&#39; seems t=
o be<br>
&gt;&gt; treated as a definition(-d) or a reference(-r).<br>
&gt;&gt;<br>
&gt;&gt; [src/main.zig from <a href=3D"https://github.com/ziglang/zig" rel=
=3D"noreferrer noreferrer noreferrer noreferrer" target=3D"_blank">https://=
github.com/ziglang/zig</a>]<br>
&gt;&gt; 150=C2=A0 =C2=A0 for (log_scopes.items) |log_scope| {=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &lt;=3D=3D definition<br>
&gt;&gt; 151=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (mem.eql(u8, log_scope, scope_na=
me)) &lt;=3D=3D reference<br>
&gt;&gt; 152=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;<br>
&gt;&gt; 153=C2=A0 =C2=A0 =C2=A0 =C2=A0 } else return;<br>
&gt;&gt;<br>
&gt;&gt; $ global -x log_scope<br>
&gt;&gt; ...<br>
&gt;&gt; log_scope=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0150 src/main.zig=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0for (log_scopes.items)<br>
&gt;&gt; |log_scope| {<br>
&gt;&gt; ...<br>
&gt;&gt; $ global -x log_scope -r<br>
&gt;&gt; ...<br>
&gt;&gt; log_scope=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0151 src/main.zig=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (mem.eql(u8,<br>
&gt;&gt; log_scope, scope_name))<br>
&gt;&gt; ...<br>
&gt;&gt;<br>
&gt;&gt; But wouldn&#39;t it be appropriate to treat it as an other symbol(=
-s)?<br>
&gt;&gt; Because other places seem to treat variables only as other symbols=
(-s).<br>
&gt;&gt;<br>
&gt;&gt; 2. Htags<br>
&gt;&gt;<br>
&gt;&gt; o Function guides(--func-header) are only at the beginning and end=
 of the file.<br>
&gt;&gt; o Definition/reference links are not displayed at all.<br>
&gt;&gt;<br>
&gt;&gt; Does this mean it&#39;s still a work in progress?<br>
&gt;&gt;<br>
&gt;&gt; And one more thing.<br>
&gt;&gt;<br>
&gt;&gt; &gt; Also changed HTML_quoting() in &#39;htags/src2html.c&#39; to =
help spot and make safe<br>
&gt;&gt; &gt; funny characters in source files, like the ones in<br>
&gt;&gt; &gt; &#39;libdb/sqlite3.c&#39; (0xB1 and 0xC4); but this change is=
 not really necessary.<br>
&gt;&gt;<br>
&gt;&gt; I would appreciate it if you could focus on one theme for each pat=
ch.<br>
&gt;&gt;<br>
&gt;&gt; Finally, thanks for all the hard work!<br>
&gt;&gt;<br>
&gt;&gt; Regards,<br>
&gt;&gt; Shigio<br>
&gt;&gt;<br>
&gt;&gt; On Sat, Sep 2, 2023 at 9:44=E2=80=AFAM Simon D &lt;<a href=3D"mail=
to:[email protected]" rel=3D"noreferrer noreferrer noreferrer" targ=
et=3D"_blank">[email protected]</a>&gt; wrote:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Hi Shigio and other Global developers,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have created Zig parsers for Gtags and Htags version 6.6.10=
.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I don&#39;t program in Zig, but have tested it on a number of=
 Zig source files.<br>
&gt;&gt; &gt; Zig is an Open Source language, so you can download its sourc=
e files.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I did modify makeincludeindex() to include the @import() func=
tions of Zig, but<br>
&gt;&gt; &gt; it didn&#39;t seem to make any difference, so I removed the c=
ode.<br>
&gt;&gt; &gt; The @import functions (like &#39;#include&#39; in C) are made=
 into HTML links with the<br>
&gt;&gt; &gt; htags parser, and they work.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Had to change compress() for names beginning with &#39;@&#39;=
 in them.<br>
&gt;&gt; &gt; I don&#39;t think you need to change the version number of th=
e format of the<br>
&gt;&gt; &gt; Global databases. I have left the &#39;@&#39; character in as=
 part of the name, like in<br>
&gt;&gt; &gt; the built-in function &#39;@ptrToInt&#39; for example, as thi=
s is what the text editor<br>
&gt;&gt; &gt; Kate also does when syntax hilighting Zig code. Thus it gets =
saved into the<br>
&gt;&gt; &gt; databases as &#39;@ptrToInt&#39;.<br>
&gt;&gt; &gt; But the HTML index htags generates, doesn&#39;t include an en=
try for names<br>
&gt;&gt; &gt; beginning with &#39;@&#39; yet, maybe one day.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Also changed HTML_quoting() in &#39;htags/src2html.c&#39; to =
help spot and make safe<br>
&gt;&gt; &gt; funny characters in source files, like the ones in<br>
&gt;&gt; &gt; &#39;libdb/sqlite3.c&#39; (0xB1 and 0xC4); but this change is=
 not really necessary.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I thought I had gone wrong with the Zig function pointers, li=
ke &#39;xxx: fn ()&#39;,<br>
&gt;&gt; &gt; that are in &#39;struct&#39; statements, as some of them don&=
#39;t get the guide/icons with<br>
&gt;&gt; &gt; them, but these function pointers are not function definition=
s.<br>
&gt;&gt; &gt; I will fix this in the next update of the Zig parsers.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I think I can add code to parse Zig function calls, so this c=
ould be a future<br>
&gt;&gt; &gt; enhancement.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have also fixed some minor text messages, code and doxygen =
code, hope they<br>
&gt;&gt; &gt; are ok.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Hope these parsers are useful for Global.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; (Feature request: a Language Server Protocol [LSP] interface)=
.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I will be sending another email soon, more bugs, mainly invol=
ving strcmp().<br>
&gt;&gt; &gt; And one bug found in __bt_first() &#39;libdb/bt_seq.c&#39; by=
 CppCheck:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; &#39;if ((h =3D xxx()) =3D=3D NULL) { if (h-&gt;pgno =3D=3D s=
ave.page-&gt;pgno) ....}&#39;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; Simon Dommett<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Shigio YAMAGUCHI &lt;<a href=3D"mailto:[email protected]" rel=3D"nore=
ferrer noreferrer noreferrer" target=3D"_blank">[email protected]</a>&gt;<br>
&gt;&gt; PGP fingerprint:<br>
&gt;&gt; 26F6 31B4 3D62 4A92 7E6F=C2=A0 1C33 969C 3BE3 89DD A6EB<br>
<br>
<br>
<br>
-- <br>
Shigio YAMAGUCHI &lt;<a href=3D"mailto:[email protected]" rel=3D"noreferrer no=
referrer noreferrer" target=3D"_blank">[email protected]</a>&gt;<br>
PGP fingerprint:<br>
26F6 31B4 3D62 4A92 7E6F=C2=A0 1C33 969C 3BE3 89DD A6EB<br>
</blockquote></div></div></div>

--000000000000835f7d0604993820--