Hi!
I'm working on a mini compiler with flex and bison. The ".l" and ".y" files are generated successfully. However, when I try to compile the hole thing using the command "gcc -o comp comp.tab.c lex.yy.c ", I keep having this error :-( In file included from comp.l:4:
comp.tab.h:56: error: expected identifier before ‘(’ token
It's supposed to be a syntax error but I honestly don't know where does it come from knowing that the file "comp.tab.h " is generated by bison...
*******comp.tab .h****** - /* A Bison parser, made by GNU Bison 2.3. */
-
....
-
......
-
/* Tokens. */
-
#ifndef YYTOKENTYPE
-
# define YYTOKENTYPE
-
/* Put the tokens into the symbol table, so that GDB and other debuggers
-
know about them. */
-
enum yytokentype {
-
INTEGER_LITERAL = 258,
-
IDENTIFIER = 259,
-
MULT = 260,
-
INT = 261,
-
NEW = 262,
-
THIS = 263,
-
BOOLEAN = 264,
-
IF = 265,
-
WHILE = 266,
-
SYSTEM_OUT_PRINTLN = 267,
-
LENGTH = 268,
-
FALSE = 269,
-
TRUE = 270,
-
ELSE = 271,
-
EOF = 272,
-
AND = 273,
-
MINUS = 274,
-
INF = 275,
-
PLUS = 276
-
};
-
#endif
-
/* Tokens. */
-
#define INTEGER_LITERAL 258
-
#define IDENTIFIER 259
-
#define MULT 260
-
#define INT 261
-
#define NEW 262
-
#define THIS 263
-
#define BOOLEAN 264
-
#define IF 265
-
#define WHILE 266
-
#define SYSTEM_OUT_PRINTLN 267
-
#define LENGTH 268
-
#define FALSE 269
-
#define TRUE 270
-
#define ELSE 271
-
#define EOF 272 // line 56
-
#define AND 273
-
#define MINUS 274
-
#define INF 275
-
#define PLUS 276
-
-
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
typedef int YYSTYPE;
-
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-
# define YYSTYPE_IS_DECLARED 1
-
# define YYSTYPE_IS_TRIVIAL 1
-
#endif
-
-
extern YYSTYPE yylval;
-
HELP please!
Thanks in advance!
5 45036
Is anything included before, like
stdin.h, where..
Try to change EOF to something else...
Hi again,
In fact I removed the lines "EOF=272" & "#define EOF 272" and the error disappeared... I guess there was a name collision or something like that...
donbock 2,426
Recognized Expert Top Contributor
Did you define a token named EOF in your grammar? If so, then you may have inadvertently directed bison to create the namespace collision. Try renaming your token and rebuilding.
JosAH 11,448
Recognized Expert MVP @nina01
Before you include that generated bison file better undefine that EOF macro first; removeing it from the list mutilates the tokenizer and it won't work properly anymore. Add the following lines before you include that generated file: -
#ifdef EOF
-
#undef EOF
-
#endif
-
Or simply use another name in your .l or .y file, e.g. ENDF will do.
kind regards,
Jos
I've renamed the token and now it works.
Thanks for all those who replied to my question!
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: sanctus |
last post by:
Is there a typical mistake which generates the error:
" error: expected primary-expression before ‘)’ token"
because I fail to see why I get this problem and the code is too big to post it here. Also just saying that it depends on the case would be very helpful so I kinow it something specific about the changes I made...
|
by: Ram Prasad |
last post by:
I am trying to write a simple libspf2 plugin code for my postfix
( milter)
I am getting this unhelpful error message when I try to compile
gcc -g1 -Wall -I/usr/local/include/spf2 -I. -c mfunc.c
In file included from mfunc.c:1:
mfunc.c:42: error: expected ')' before '*' token
make: *** Error 1
my mfunc.c has on the line 42
|
by: gyre |
last post by:
Hi!
I've got a little problem I've been dealing with for several days :((
Code is written in Qt.
I'll try to explain it:
I created an abstract class "VcaNode" with 4 virtual methods and 3 other members...it is in special header:
//ABSTRACT CLASS MEMBER:
#ifndef _VCA_NODE
#define _VCA_NODE
|
by: amitmool |
last post by:
hi, i have used the queue library file and try to use the template as
template <class QueueItem>
queue <QueueItem>::~queue() // line 25
{
}
template <class QueueItem>
void queue<QueueItem>::push(const QueueItem& entry) // line 42
|
by: anju1401 |
last post by:
Hi
I am using WINAVR compiler for ATMEGA32. While compiling c progam , I am getting the error
error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before '{' token
before evrey function.
code:
#include <avr\io.h>
| |
by: bals3239 |
last post by:
I am using a program called putty to write basic programs in C/ C++ for an introduction to computer programming class. I am very new at programming and am just getting started writing very simple programs. When I try to compile my programs, I receive an error message saying
error: expected identifier or â(â before â{â token
and am...
|
by: sam23 |
last post by:
Hi all, im new to this programming language and i tried to use my Xcode to build and run this code but i got a error :(, and another error is
i need a help guys
#include <GLUT/glut.h>
#include <stdlib.h>
#include <math.h>
|
by: mikr |
last post by:
I'm new to jquery, and hoping it will make my client side coding more friendly (particularly with regards to ie).
As is usually the case, I've got some code that works nicely in ff, but kicks out an "Expected Identifier" error.
So, I've got two questions:
What exactly does that mean? What is an "Identifier," particularly within the context...
|
by: Phacer |
last post by:
When trying to compile I get this
/main.c:30: error: expected identifier or '(' before '{' token
../main.c:31: error: expected identifier or '(' before 'if'
make: *** Error 1
SDL_SysWMinfo info;
SDL_VERSION(&info.version);
if ( SDL_GetWMInfo(&info) ) {
Display *dpy = info.info.x11.display;
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |