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

  • Home
  • SEARCH
  • 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 6152443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:55:16+00:00 2026-05-23T19:55:16+00:00

I have a C header file that I have precompiled using the gcc -E

  • 0

I have a C header file that I have precompiled using the gcc -E flag, and am now trying to parse using Lex and Yacc; however, it is getting hung up on typedef’d variables.

for example:

typedef unsigned long ULONG;
ULONG i = 5;

will throw a syntax error at the second line’s ULONG.

I have tried to redefine part of the grammar (found here) http://www.quut.com/c/ANSI-C-grammar-y.html, specifically under type_specifer by replacing TYPE_NAME with IDENTIFIER, however that create multiple s/r and r/r errors that I am unable to fix.

Are there other approaches that you would recommend?
Or a different approach at precompiling all together?

  • 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-23T19:55:17+00:00Added an answer on May 23, 2026 at 7:55 pm

    In the code you link too:
    http://www.quut.com/c/ANSI-C-grammar-y.html,

    look at the bottom:
    You will see this function

    int check_type(void)
    {
     /*
      * pseudo code --- this is what it should check
      *
      * if (yytext == type_name)
      *     return TYPE_NAME;
      *
      * return IDENTIFIER;
      */
    
    /*
     *  it actually will only return IDENTIFIER
     */
    
        return IDENTIFIER;
    }
    

    You actually need to write the code that identifies weather a sequence (yytest, yytext+yylength] is an identifier or a TYPE_NAME. This means in the parser you need to build some structure as you parse the code so that this function can look up the identifier in the structure.

    Pre-populate the structure with the default types char/int/short/long/float/double etc. The other types you will need to add as you parse the input.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a plist that is processed with a precompiled header file and in
I have a header file, lets say Common.h, that is included in all of
I have a flat-file schema that has a header and detail records. It looks
I have a header file that has some forward declarations but when I include
I have a header ( .h ) file that I've defined a bunch of
I have a header file called stdafx.h and this one is precompiled of course.
I have set a header file's role in Xcode to private so that it
I have a header file that has some static variables for all of my
I have a header file that has a number of declarations like this: extern
I have a header file that looks like header.h int TOS; This file is

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.