Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug? handling <...> #10

Closed
masatake opened this issue Jun 28, 2024 · 3 comments
Closed

bug? handling <...> #10

masatake opened this issue Jun 28, 2024 · 3 comments

Comments

@masatake
Copy link
Contributor

I'm integrating pegof with the build system of Universal Ctags (universal-ctags/ctags#4026).

During the integration, I found a bug of pegof.

[yamato@dev64]~/var/ctags-github% touch peg/varlink.peg  
[yamato@dev64]~/var/ctags-github% make V=1             
./misc/gen-repoinfo main/repoinfo.h
make  all-recursive
make[1]: Entering directory '/home/yamato/var/ctags-github'
Making all in gnulib
make[2]: Entering directory '/home/yamato/var/ctags-github/gnulib'
make  all-recursive
make[3]: Entering directory '/home/yamato/var/ctags-github/gnulib'
make[4]: Entering directory '/home/yamato/var/ctags-github/gnulib'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/home/yamato/var/ctags-github/gnulib'
make[3]: Leaving directory '/home/yamato/var/ctags-github/gnulib'
make[2]: Leaving directory '/home/yamato/var/ctags-github/gnulib'
Making all in .
make[2]: Entering directory '/home/yamato/var/ctags-github'
./misc/gen-repoinfo main/repoinfo.h
../pegof/build/pegof -O all -o ./peg/varlink.pego -i "peg/varlink.peg"
./packcc -o ./peg/varlink ./peg/varlink.pego
gcc -DHAVE_CONFIG_H -I.  -I. -I. -I./main -I./dsl -I./peg -DHAVE_PACKCC  -DUSE_SYSTEM_STRNLEN -DHAVE_PEGOF -I./gnulib -I./gnulib -DHAVE_REPOINFO_H  -std=gnu99 -Wall   -I/usr/include/libxml2 -DWITH_GZFILEOP     -g -O2 -MT peg/libctags_a-varlink.o -MD -MP -MF peg/.deps/libctags_a-varlink.Tpo -c -o peg/libctags_a-varlink.o `test -f 'peg/varlink.c' || echo './'`peg/varlink.c
In file included from peg/varlink_pre.h:15,
                 from peg/varlink.c:28:
peg/varlink.c: In function ‘pcc_action_name_0’:
peg/varlink.c:1177:44: error: ‘_1’ undeclared (first use in this function); did you mean ‘_0’?
 1177 |     SET_SCOPE(auxil, makeVarlinkTag(auxil, _1, _1s));
      |                                            ^~
peg/peg_common.h:46:42: note: in definition of macro ‘SET_SCOPE’
   46 | #define SET_SCOPE(P,S) (BASE_SCOPE(P) = (S))
      |                                          ^
peg/varlink.c:1177:44: note: each undeclared identifier is reported only once for each function it appears in
 1177 |     SET_SCOPE(auxil, makeVarlinkTag(auxil, _1, _1s));
      |                                            ^~
peg/peg_common.h:46:42: note: in definition of macro ‘SET_SCOPE’
   46 | #define SET_SCOPE(P,S) (BASE_SCOPE(P) = (S))
      |                                          ^
peg/varlink.c:1177:48: error: ‘_1s’ undeclared (first use in this function); did you mean ‘_0s’?
 1177 |     SET_SCOPE(auxil, makeVarlinkTag(auxil, _1, _1s));
      |                                                ^~~
peg/peg_common.h:46:42: note: in definition of macro ‘SET_SCOPE’
   46 | #define SET_SCOPE(P,S) (BASE_SCOPE(P) = (S))
      |                                          ^
make[2]: *** [Makefile:6362: peg/libctags_a-varlink.o] Error 1
make[2]: Leaving directory '/home/yamato/var/ctags-github'
make[1]: *** [Makefile:6746: all-recursive] Error 1
make[1]: Leaving directory '/home/yamato/var/ctags-github'
make: *** [Makefile:2367: all] Error 2

I compared varlink.peg (the input for pegof) and varlink.pego (the output of pegof):

.peg

name
    <- < [A-Z][A-Za-z0-9]* > {
    if (PEEK_KIND (auxil) != KIND_GHOST_INDEX)
       SET_SCOPE(auxil, makeVarlinkTag(auxil, $1, $1s));
}

.pego

name <-
    [A-Z] [0-9A-Za-z]* { if (PEEK_KIND (auxil) != KIND_GHOST_INDEX)
       SET_SCOPE(auxil, makeVarlinkTag(auxil, $1, $1s)); }

pegof removes < and >. So $1 lost the sense.
Should I turn unused-capture optimization off?

@dolik-rce
Copy link
Owner

Thanks for the detailed report @masatake.

Should I turn unused-capture optimization off?

Yes, you can try to identify the problematic optimization and turn it off, as a temporary workaround.

@masatake
Copy link
Contributor Author

masatake commented Jun 29, 2024

Thank you. All peg-based parsers are built well with -O all -X unused-capture.
I will keep this one open.

@dolik-rce
Copy link
Owner

Should be fixed now, there was a stupid problem with the regexp that makes the check, so it didn't work correctly for multiline actions.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants