mdhender / cook

Peter Miller's cook
GNU General Public License v3.0
7 stars 4 forks source link

Build fails with yac error #20

Open hoxnox opened 2 years ago

hoxnox commented 2 years ago

I don't know what to do with this. Can anybody point the root of the problem?

gcc  -g -O2 -I. -c common/sub/expr_gram.yacc.c
In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from ./common/ac/stdio.h:25,
                 from common/sub/expr_gram.y:23:
/usr/include/features.h:187:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
  187 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~
y.tab.c:147:29: error: expected identifier or ‘(’ before numeric constant
common/sub/expr_gram.y:92:1: note: in expansion of macro ‘sub_expr_gram_error’
   92 | yyerror(char *s)
      | ^~~~~~~~~~~~~~~~   
y.tab.c: In function ‘sub_expr_gram_parse’:
y.tab.c:147:29: error: called object is not a function or function pointer
y.tab.c:1338:7: note: in expansion of macro ‘sub_expr_gram_error’
y.tab.c:147:29: error: called object is not a function or function pointer
y.tab.c:1449:3: note: in expansion of macro ‘sub_expr_gram_error’
make: *** [Makefile:769: common/sub/expr_gram.yacc.o] Error 1
mdhender commented 2 years ago

Does https://github.com/mdhender/cook/issues/16#issuecomment-907494405 help?

hoxnox commented 2 years ago

Does #16 (comment) help?

Unfortunately, no. The problem is not in that warning. But may be below. I don't know yacc, so it's very hard for me to understand the root of the problem.

bison -y -d common/sub/expr_gram.y
common/sub/expr_gram.y:52.19-24: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]
   52 | %type <lv_number> NUMBER expr
      |                   ^~~~~~
sed -e 's/[yY][yY]/sub_expr_gram_/g' y.tab.c > \
        common/sub/expr_gram.yacc.c
sed -e 's/[yY][yY]/sub_expr_gram_/g' y.tab.h > \
        common/sub/expr_gram.yacc.h
rm y.tab.c y.tab.h
gcc  -D _DEFAULT_SOURCE -I. -c common/sub/expr_gram.yacc.c
y.tab.c: In function 'sub_expr_gram_parse':
y.tab.c:147:29: error: called object is not a function or function pointer
y.tab.c:1324:7: note: in expansion of macro 'sub_expr_gram_error'
y.tab.c:147:29: error: called object is not a function or function pointer
y.tab.c:1435:3: note: in expansion of macro 'sub_expr_gram_error'
make: *** [Makefile:769: common/sub/expr_gram.yacc.o] Error 1
hoxnox commented 2 years ago

There are many such problems. They all connected with yyerror:

bison -y -d cook/hashline.y
cook/hashline.y:867.21-33: warning: POSIX yacc reserves %type to nonterminals [-Wyacc]                                                                                
  867 | %type <lv_word>     HASHLINE_WORD
      |                     ^~~~~~~~~~~~~
sed -e 's/[yY][yY]/hashline_/g' y.tab.c > cook/hashline.yacc.c
sed -e 's/[yY][yY]/hashline_/g' y.tab.h > cook/hashline.yacc.h
rm y.tab.c y.tab.h
gcc  -D _DEFAULT_SOURCE -I. -c cook/hashline.yacc.c
cook/hashline.y:79:24: error: 'parse_error' redeclared as different kind of symbol
   79 | #define yyerror parse_error
      |                        ^~~~       
y.tab.c:919:5: note: in expansion of macro 'hashline_error'
In file included from cook/hashline.y:52:
./cook/lex.h:49:6: note: previous declaration of 'parse_error' with type 'void(char *)'
   49 | void parse_error(char *);
      |      ^~~~~~~~~~~
y.tab.c:943: warning: "hashline_error" redefined
cook/hashline.y:79: note: this is the location of the previous definition
   79 | #define yyerror parse_error
      | 
y.tab.c: In function 'hashline_parse':
y.tab.c:943:24: error: called object is not a function or function pointer
y.tab.c:2173:7: note: in expansion of macro 'hashline_error'
y.tab.c:943:24: error: called object is not a function or function pointer
y.tab.c:2284:3: note: in expansion of macro 'hashline_error'
make: *** [Makefile:1871: cook/hashline.yacc.o] Error 1
hoxnox commented 2 years ago

Looks like this part makes some evil because of mess YY and yy.

common/sub/expr_gram.yacc.c common/sub/expr_gram.yacc.h: \
        common/sub/expr_gram.y
    $(YACC) -d common/sub/expr_gram.y
    sed -e 's/[yY][yY]/sub_expr_gram_/g' y.tab.c > \
        common/sub/expr_gram.yacc.c
    sed -e 's/[yY][yY]/sub_expr_gram_/g' y.tab.h > \
        common/sub/expr_gram.yacc.h
    rm y.tab.c y.tab.h
hoxnox commented 2 years ago

I've build statically linked binaries for Linux: https://github.com/hoxnox/cook/releases/download/v2.35/cook-2.35.tar.gz you can attach them to the release

fredfox1 commented 1 year ago

I just attempted a build on a fresh install of Ubuntu 22.04. "make" fails exactly as described in the initial issue submission above.

The build succeeds on Ubuntu 20.04

I applied the FIX to Makefile.in by "hoxnox" and the build succeeds on both 20.04 and 22.04. The tests "make sure" succeed and fail the same on both systems. I was able to "cook" my project on the 22.04