Re: Zig parsers for Global
Simon D <[email protected]> Thu, 7 Sep 2023 08:08:10 +0100
| Newsgroups | gmane.comp.gnu.global.bugs |
|---|---|
| Message-ID | <CA+i7qFiu1VMTmtM1Ks4rGr56t30c+-1YG25aRC7eDNkP3_fYag@mail.gmail.com> |
--00000000000031b3ab0604bf89d2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Shigio, Please can you change the following values in both 'zig.l' files and try building again. ALPHA [a-zA-Z_\x80-\xff] ALPHANUM [a-zA-Z0-9_\x80-\xff] If it is these that are stopping Global on your machine from working properly with Zig, as I cannot test this on my machine. I do not have a Japanese character set. I have change these on my machine and the Zig parsers still work. Thanks Simon On Tue, 5 Sept 2023, 10:25 Simon D, <[email protected]> wrote: > > 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 th= e >> 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]= m> wrote: >> > >> > Hi, >> > >> > > 150 for (log_scopes.items) |log_scope| { <=3D=3D >> definition >> > >> > 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 th= e >> 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 defi= nition >> >> 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 sourc= e >> files. >> >> > Zig is an Open Source language, so you can download its source file= s. >> >> > >> >> > I did modify makeincludeindex() to include the @import() functions >> of 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 >> links 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 o= f >> 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 >> names >> >> > 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 b= e >> 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->pgn= o) ....}' >> >> > >> >> > >> >> > >> >> > 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 >> > --00000000000031b3ab0604bf89d2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"auto"><div>Hi Shigio,</div><div dir=3D"auto"><br></div><div dir= =3D"auto">Please can you change the following values in both 'zig.l'= ; files and try building again.</div><div dir=3D"auto"><div dir=3D"auto" st= yle=3D"font-size:12.8px"><span style=3D"font-family:monospace;font-size:med= ium;background-color:rgb(255,255,255)"><br></span></div><div dir=3D"auto" s= tyle=3D"font-size:12.8px"><span style=3D"font-family:monospace;font-size:me= dium;background-color:rgb(255,255,255)">ALPHA [a-zA-Z_\x80-\xff]</sp= an></div><div dir=3D"auto" style=3D"font-size:12.8px"><font face=3D"monospa= ce" size=3D"3">ALPHANUM=C2=A0 =C2=A0 =C2=A0[a-zA-Z0-9_\x80-\xff]</font></di= v><div dir=3D"auto"><br></div>If it is these that are stopping Global on yo= ur machine from working properly with Zig,</div><div dir=3D"auto">as I cann= ot test this on my machine.=C2=A0 I do not have a Japanese character set.</= div><div dir=3D"auto"><br></div><div dir=3D"auto">I have change these on my= machine and the Zig parsers still work.</div><div dir=3D"auto"><br></div><= div dir=3D"auto">Thanks</div><div dir=3D"auto"><br></div><div dir=3D"auto">= Simon</div><div dir=3D"auto"><br></div><div dir=3D"auto"><br><div class=3D"= gmail_quote" dir=3D"auto"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, 5 S= ept 2023, 10:25 Simon D, <<a href=3D"mailto:[email protected]">s= [email protected]</a>> wrote:<br></div><blockquote class=3D"gmail= _quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:= 1ex"><div dir=3D"auto"><div dir=3D"auto">> Other parsers don't treat= variable definitions to be definitions. So I<br>> think you should adju= st accordingly.<br></div><div dir=3D"auto"><br></div><div dir=3D"auto">Ok</= div><div dir=3D"auto"><br></div><div dir=3D"auto">> No, that's not w= hat I meant. I'm talking about the links on the source code.<br></div><= div dir=3D"auto"><br></div><div>Does Japanese use character byte values >= ;=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"fo= nt-family:monospace;font-size:medium;white-space:pre-wrap;background-color:= rgb(255,255,255)">In yours: ALPHA [a-zA-Z_\x80-\xff]</span></div><d= iv dir=3D"auto"><font face=3D"monospace" size=3D"3"><span> ALPHAN= UM [a-zA-Z0-9_\x80-\xff]</span></font></div><div dir=3D"auto"><span sty= le=3D"font-family:monospace;font-size:medium;white-space:pre-wrap;backgroun= d-color:rgb(255,255,255)">In mine: </span><span style=3D"background-color= :rgb(255,255,255);font-family:monospace;font-size:medium;white-space:pre-wr= ap">ALPHA [a-zA-Z_]</span></div><div dir=3D"auto"><span style=3D"bac= kground-color:rgb(255,255,255)"><font face=3D"monospace" size=3D"3"><span> = ALPHANUM [a-zA-Z0-9_]</span></font></span></div><div dir=3D"a= uto"><div dir=3D"auto"><br></div></div>Sounds like that could be the proble= m, sorry.</div><div dir=3D"auto"><br></div><div dir=3D"auto">Simon</div><di= v dir=3D"auto"><br><br><div class=3D"gmail_quote" dir=3D"auto"><div dir=3D"= ltr" class=3D"gmail_attr">On Tue, 5 Sept 2023, 08:41 Shigio YAMAGUCHI, <= <a href=3D"mailto:[email protected]" rel=3D"noreferrer noreferrer noreferrer" = target=3D"_blank">[email protected]</a>> wrote:<br></div><blockquote class= =3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd= ing-left:1ex">Hi,<br> > From what I gathered about the '|x|' statement in Zig, it is l= ike an index variable,<br> > like the first 'y' in the C/C++ code 'for(int y =3D 0; y &= lt; 4;)', that's why I made it<br> > a definition; can change it if you like.<br> <br> Other parsers don'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> > > o Definition/reference links are not displayed at all.<br> ><br> > It is just the names beginning with a '@' that are not display= ed in the htags main<br> > 'Definitions' (index), I thought.<br> <br> No, that's not what I meant. I'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've processed zig source code<br> (<a href=3D"https://github.com/ziglang/zig" rel=3D"noreferrer noreferrer no= referrer noreferrer noreferrer" target=3D"_blank">https://github.com/ziglan= g/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 <<a href=3D"mailto:si.oct= [email protected]" rel=3D"noreferrer noreferrer noreferrer noreferrer" ta= rget=3D"_blank">[email protected]</a>> wrote:<br> ><br> > Hi,<br> ><br> > > 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 <=3D=3D definition<br> ><br> > From what I gathered about the '|x|' statement in Zig, it is l= ike an index variable, like the first 'y' in the C/C++ code 'fo= r(int y =3D 0; y < 4;)', that's why I made it a definition; can = change it if you like.<br> > Then on the next line 'if (mem.eql(u8, log_scope, ...' , it wo= uld be a reference.<br> ><br> > > o Definition/reference links are not displayed at all.<br> ><br> > It is just the names beginning with a '@' that are not display= ed in the htags main 'Definitions' (index), I thought.<br> ><br> > > Does this mean it's still a work in progress?<br> ><br> > Yes<br> ><br> > > Finally, thanks for all the hard work!<br> ><br> > Thanks<br> ><br> > Simon<br> ><br> ><br> > On Tue, 5 Sept 2023, 05:17 Shigio YAMAGUCHI, <<a href=3D"mailto:shi= [email protected]" rel=3D"noreferrer noreferrer noreferrer noreferrer" target=3D"= _blank">[email protected]</a>> wrote:<br> >><br> >> Hi<br> >> Please let me make a few comments.<br> >><br> >> 1. Gtags<br> >><br> >> In the following source code, variable 'log_scope' seems t= o be<br> >> treated as a definition(-d) or a reference(-r).<br> >><br> >> [src/main.zig from <a href=3D"https://github.com/ziglang/zig" rel= =3D"noreferrer noreferrer noreferrer noreferrer noreferrer" target=3D"_blan= k">https://github.com/ziglang/zig</a>]<br> >> 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 <=3D=3D definition<br> >> 151=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (mem.eql(u8, log_scope, scope_na= me)) <=3D=3D reference<br> >> 152=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 break;<br> >> 153=C2=A0 =C2=A0 =C2=A0 =C2=A0 } else return;<br> >><br> >> $ global -x log_scope<br> >> ...<br> >> 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> >> |log_scope| {<br> >> ...<br> >> $ global -x log_scope -r<br> >> ...<br> >> 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> >> log_scope, scope_name))<br> >> ...<br> >><br> >> But wouldn't it be appropriate to treat it as an other symbol(= -s)?<br> >> Because other places seem to treat variables only as other symbols= (-s).<br> >><br> >> 2. Htags<br> >><br> >> o Function guides(--func-header) are only at the beginning and end= of the file.<br> >> o Definition/reference links are not displayed at all.<br> >><br> >> Does this mean it's still a work in progress?<br> >><br> >> And one more thing.<br> >><br> >> > Also changed HTML_quoting() in 'htags/src2html.c' to = help spot and make safe<br> >> > funny characters in source files, like the ones in<br> >> > 'libdb/sqlite3.c' (0xB1 and 0xC4); but this change is= not really necessary.<br> >><br> >> I would appreciate it if you could focus on one theme for each pat= ch.<br> >><br> >> Finally, thanks for all the hard work!<br> >><br> >> Regards,<br> >> Shigio<br> >><br> >> On Sat, Sep 2, 2023 at 9:44=E2=80=AFAM Simon D <<a href=3D"mail= to:[email protected]" rel=3D"noreferrer noreferrer noreferrer noref= errer" target=3D"_blank">[email protected]</a>> wrote:<br> >> ><br> >> ><br> >> > Hi Shigio and other Global developers,<br> >> ><br> >> > I have created Zig parsers for Gtags and Htags version 6.6.10= .<br> >> ><br> >> > I don't program in Zig, but have tested it on a number of= Zig source files.<br> >> > Zig is an Open Source language, so you can download its sourc= e files.<br> >> ><br> >> > I did modify makeincludeindex() to include the @import() func= tions of Zig, but<br> >> > it didn't seem to make any difference, so I removed the c= ode.<br> >> > The @import functions (like '#include' in C) are made= into HTML links with the<br> >> > htags parser, and they work.<br> >> ><br> >> > Had to change compress() for names beginning with '@'= in them.<br> >> > I don't think you need to change the version number of th= e format of the<br> >> > Global databases. I have left the '@' character in as= part of the name, like in<br> >> > the built-in function '@ptrToInt' for example, as thi= s is what the text editor<br> >> > Kate also does when syntax hilighting Zig code. Thus it gets = saved into the<br> >> > databases as '@ptrToInt'.<br> >> > But the HTML index htags generates, doesn't include an en= try for names<br> >> > beginning with '@' yet, maybe one day.<br> >> ><br> >> > Also changed HTML_quoting() in 'htags/src2html.c' to = help spot and make safe<br> >> > funny characters in source files, like the ones in<br> >> > 'libdb/sqlite3.c' (0xB1 and 0xC4); but this change is= not really necessary.<br> >> ><br> >> > I thought I had gone wrong with the Zig function pointers, li= ke 'xxx: fn ()',<br> >> > that are in 'struct' statements, as some of them don&= #39;t get the guide/icons with<br> >> > them, but these function pointers are not function definition= s.<br> >> > I will fix this in the next update of the Zig parsers.<br> >> ><br> >> > I think I can add code to parse Zig function calls, so this c= ould be a future<br> >> > enhancement.<br> >> ><br> >> > I have also fixed some minor text messages, code and doxygen = code, hope they<br> >> > are ok.<br> >> ><br> >> > Hope these parsers are useful for Global.<br> >> ><br> >> > (Feature request: a Language Server Protocol [LSP] interface)= .<br> >> ><br> >> > I will be sending another email soon, more bugs, mainly invol= ving strcmp().<br> >> > And one bug found in __bt_first() 'libdb/bt_seq.c' by= CppCheck:<br> >> ><br> >> > 'if ((h =3D xxx()) =3D=3D NULL) { if (h->pgno =3D=3D s= ave.page->pgno) ....}'<br> >> ><br> >> ><br> >> ><br> >> > Simon Dommett<br> >> ><br> >><br> >><br> >> --<br> >> Shigio YAMAGUCHI <<a href=3D"mailto:[email protected]" rel=3D"nore= ferrer noreferrer noreferrer noreferrer" target=3D"_blank">[email protected]</= a>><br> >> PGP fingerprint:<br> >> 26F6 31B4 3D62 4A92 7E6F=C2=A0 1C33 969C 3BE3 89DD A6EB<br> <br> <br> <br> -- <br> Shigio YAMAGUCHI <<a href=3D"mailto:[email protected]" rel=3D"noreferrer no= referrer noreferrer noreferrer" target=3D"_blank">[email protected]</a>><br= > PGP fingerprint:<br> 26F6 31B4 3D62 4A92 7E6F=C2=A0 1C33 969C 3BE3 89DD A6EB<br> </blockquote></div></div></div> </blockquote></div></div></div> --00000000000031b3ab0604bf89d2--