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 6702069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T07:00:35+00:00 2026-05-26T07:00:35+00:00

I am using bison to implement a simple parser. And one line of the

  • 0

I am using bison to implement a simple parser. And one line of the syntax looks like:

prefix_definition : PREFIX IDENTIFIER IDENTIFIER ABBR IDENTIFIER ';'

I am unsure how to access the 1st, 2nd and 3rd IDENTIFIER separately. My flex file reads the IDENTIFIER like this:

IDENTIFIER_REGEX (_|[A_Za-z])(_|[0-9A-Za-z])*

{IDENTIFIER_REGEX}     { yylval.identifier=strdup(yytext); return IDENTIFIER; }

I could not use simply yylval.identifier. I tried $2.identifier or so but it simply does not work(and it is not supposed to be work anyway). Is there any way of solving this problem?

I am considering to use a FIFO queue if the bison/flex does not support such access. Is this a good solution?

  • 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-26T07:00:35+00:00Added an answer on May 26, 2026 at 7:00 am

    You can specify the type of a token while declaring it (in the bison file) the same way you would for nonterminals (where you’d use %type) like so:

    %token <identifier> IDENTIFIER
    

    (where identifier is one of the fields declared in the %union). Then $2, $3 and so on will point to the right thing, without needing to go through yylval (i.e. they will be char *s in your case).

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

Sidebar

Related Questions

I would like to create simple C++ calculator using bison and flex. Please note
I'm using Bison to create a simple parser and have some trouble understanding the
I'm trying to parse a simple grammar using an LALR(1) parser generator (Bison, but
i am developing parser using bison...in my grammar i am getting this error Here
I have just been re-working an old bit of compiler-like code written using bison.
I'm using Flex and Bison for a parser generator, but having problems with the
I am developing a simple compiler in the cygwin environment using flex and bison
I've developed an equation parser using a simple stack algorithm that will handle binary
I want to create a read-eval-print loop using flex/bison parser. Trouble is, the flex
I'm writing a parser using Bison, and am using a map for semantic evaluation.

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.