help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Error when compiling - error: too many arguments to function ‘int yylex(


From: Craig Sanders
Subject: Error when compiling - error: too many arguments to function ‘int yylex()’
Date: Wed, 30 Mar 2022 21:33:43 +1100

Hello.

I have a very basic grammar contained within a file called SimpleParser.yy,
which I can seemingly process successfully with GNU Bison, but which I
can't then seem to compile with GNU g++. When I compile the resulting GNU
Bison output file, i.e. SimpleParser.tab.cc, I get the following error
messages;

SimpleParser.tab.cc: In member function ‘virtual int yy::parser::parse()’:
SimpleParser.tab.cc:501:58: error: too many arguments to function ‘int
yylex()’
  501 |             yyla.kind_ = yytranslate_ (yylex (&yyla.value));
      |                                                          ^
./SimpleParser.yy:14:1: note: declared here
   14 | yylex
      | ^~~~~

The command which I use to invoke GNU Bison is;

/home/craig/local/bison-3.8/bin/bison --verbose \
                                      --language=c++ \
                                      --defines="SimpleParser.tab.hpp" \
                                      ./SimpleParser.yy

This command doesn't display any output at the command prompt after I run
it, so I assume that it has processed the input file SimpleParser.yy
successfully. For what it is worth, the contents of the file
SimpleParser.yy are as follows;

%skeleton "lalr1.cc"

%{

#include <iostream>

using std::cout;
using std::endl;

extern
int
yylex
(
 void
);

extern
int
yyerror
(
 char const *
);

%}

%token  COMMAND_CREATE_NODE;

%%

assignment : COMMAND_CREATE_NODE
    {
        cout << "Symbol encountered : COMMAND_CREATE_NODE" << endl;
    };

%%

Personally, I think the contents of this file look innocent enough. More of
a concern to me is why the compiler is complaining about the  invocation of
the function yylex on line 501 of the C++ file which was generated by GNU
Bison, i.e. SimpleParser.cpp. I thought the yylex function wasn't meant to
take any arguments? Why then on line 501 is it receiving an argument of;

&yyla.value

Am I missing something here; either in the contents of the .yy file or the
way in which GNU Bison is being invoked? Is it perhaps, to do with the fact
that I am asking GNU Bison to generate C++ code? Or maybe I've just been
looking at too much documentation and the answer has been staring me in the
face.

Any help on this matter would be immensely appreciated.

Thanks in advance.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]