473,569 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error: expected identifier before ‘(’ token

8 New Member
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******
Expand|Select|Wrap|Line Numbers
  1. /* A Bison parser, made by GNU Bison 2.3.  */
  2. ....
  3. ......
  4. /* Tokens.  */
  5. #ifndef YYTOKENTYPE
  6. # define YYTOKENTYPE
  7.    /* Put the tokens into the symbol table, so that GDB and other debuggers
  8.       know about them.  */
  9.    enum yytokentype {
  10.      INTEGER_LITERAL = 258,
  11.      IDENTIFIER = 259,
  12.      MULT = 260,
  13.      INT = 261,
  14.      NEW = 262,
  15.      THIS = 263,
  16.      BOOLEAN = 264,
  17.      IF = 265,
  18.      WHILE = 266,
  19.      SYSTEM_OUT_PRINTLN = 267,
  20.      LENGTH = 268,
  21.      FALSE = 269,
  22.      TRUE = 270,
  23.      ELSE = 271,
  24.      EOF = 272,
  25.      AND = 273,
  26.      MINUS = 274,
  27.      INF = 275,
  28.      PLUS = 276
  29.    };
  30. #endif
  31. /* Tokens.  */
  32. #define INTEGER_LITERAL 258
  33. #define IDENTIFIER 259
  34. #define MULT 260
  35. #define INT 261
  36. #define NEW 262
  37. #define THIS 263
  38. #define BOOLEAN 264
  39. #define IF 265
  40. #define WHILE 266
  41. #define SYSTEM_OUT_PRINTLN 267
  42. #define LENGTH 268
  43. #define FALSE 269
  44. #define TRUE 270
  45. #define ELSE 271
  46. #define EOF 272     // line 56
  47. #define AND 273
  48. #define MINUS 274
  49. #define INF 275
  50. #define PLUS 276
  51.  
  52. #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
  53. typedef int YYSTYPE;
  54. # define yystype YYSTYPE /* obsolescent; will be withdrawn */
  55. # define YYSTYPE_IS_DECLARED 1
  56. # define YYSTYPE_IS_TRIVIAL 1
  57. #endif
  58.  
  59. extern YYSTYPE yylval;
  60.  
HELP please!
Thanks in advance!
Jan 23 '09 #1
5 45036
newb16
687 Contributor
Is anything included before, like
stdin.h, where..
Expand|Select|Wrap|Line Numbers
  1. #define    EOF    (-1)
  2.  
Try to change EOF to something else...
Jan 23 '09 #2
nina01
8 New Member
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...
Jan 23 '09 #3
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.
Jan 24 '09 #4
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:

Expand|Select|Wrap|Line Numbers
  1. #ifdef EOF
  2. #undef EOF
  3. #endif
  4.  
Or simply use another name in your .l or .y file, e.g. ENDF will do.

kind regards,

Jos
Jan 24 '09 #5
nina01
8 New Member
I've renamed the token and now it works.
Thanks for all those who replied to my question!
Jan 24 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
22240
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...
21
35495
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
5
15308
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
5
7964
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
10
31965
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>
1
20218
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...
12
18285
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>
1
3660
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...
5
26256
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;
0
7698
marktang
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...
0
7612
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...
0
7924
Oralloy
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. ...
0
8122
jinu1996
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...
0
7970
tracyyun
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...
0
6284
agi2029
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...
1
5513
isladogs
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...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1213
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.