Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1027037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:10:43+00:00 2026-05-16T12:10:43+00:00

In my parser, I have %union { SYMTABLE *p_entry ; QUAD *p_quad ; }

  • 0

In my parser, I have

%union {
  SYMTABLE *p_entry ;
  QUAD *p_quad ; 
} ;

Now, SYMTABLE is the typedef for a struct. The struct and typedef are in an included file. There are no issues with this.

QUAD is the typedef for a struct (typedef struct quad QUAD). The struct and typedef are in an included file.

There is no problem doing:

bison -d parser.y
gcc parser.tab.c -c

My lexer needs yylval, so in the declarations part I have

#include "parser.tab.h" /* bison generated header file */
extern YYSTYPE yylval ;

When I do

flex scanner.lex
gcc lex.yy.c -c

GCC complains

In file included from scanner.lex:16:
parser.y:30: error: syntax error before "QUAD"
parser.y:30: warning: no semicolon at end of struct or union
parser.y:32: error: syntax error before '}' token
parser.y:32: warning: data definition has no type or storage class
parser.tab.h:121: error: syntax error before "yylval"
parser.tab.h:121: warning: data definition has no type or storage class

If I go back to my parser.y file and replace QUAD with struct quad in ONLY the yylval %union, the problem goes away. I want to say this is a silly typedef mistake, but the bison generated file compiles just fine. I have included the header file for my QUAD typedef and struct quad in my scanner.

It seems this is the only place where the issues occurs, so I could just replace QUAD with struct quad, but this is inconsistent with the SYMTABLE.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T12:10:43+00:00Added an answer on May 16, 2026 at 12:10 pm

    my test.l:

    %{
    #include "bla.h"
    #include "test.tab.h" /* bison generated header file */
    extern YYSTYPE yylval ;
    %}
    
    %%
    \n      printf("nl");
    .       printf("c");
    %%
    

    my test.y:

    %{
    #include "bla.h"
    %}
    
    %union {
            SYMTABLE *p_entry ;
            QUAD *p_quad ; 
    };
    
    %%
    
    input:
    | input;
    
    %%
    

    my bla.h:

    typedef void *SYMTABLE;
    typedef void *QUAD;
    

    my build:

    freundt@segen:pts/21:~/temp> bison -d test.y
    test.y: conflicts: 1 shift/reduce
    test.y:13.3-7: warning: rule useless in parser due to conflicts: input: input
    freundt@segen:pts/21:~/temp> flex test.l    
    freundt@segen:pts/21:~/temp> icc lex.yy.c -c
    freundt@segen:pts/21:~/temp> 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a vcf parser and I have the file open but now
I have the following parser grammar (this is a small sample): expr: ident assignop
I have been using a SAX parser for a while now to get data
I have an XML file which XML parser choke on. A part of it
For a small AST parser i have a small discriminated union type Numerical =
Ok so If I have a parser like this example = argparse.ArgumentParser(description='main parser') example.add_argument('Kill')
I have a parser that seems straight-forward enough. I added this sub-parser to the
I have a parser myParser which can read a file using < e.g. if
I have a parser that we implemented and I want to compare it to
I have a parser with me generated from yacc/lex. It is working fine for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.