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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:12:04+00:00 2026-06-15T17:12:04+00:00

My bison / flex parser start by reading input from a file: FILE *myfile

  • 0

My bison / flex parser start by reading input from a file:

FILE *myfile = fopen(file.c_str(), "r");
yyin = myfile;
yyparse();

At some point after that, it reads and parse input from a string in memory:

yy_scan_string(str.c_str());
yyparse();
yy_delete_buffer(YY_CURRENT_BUFFER);

It seems to work well up to this point. However, when the program needs to read and parse input from the file again using the first code it doesn’t work (terminates with segmentation fault). Is there a fix to this issue?

  • 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-06-15T17:12:05+00:00Added an answer on June 15, 2026 at 5:12 pm

    I think I figured it out, simply by pushing and poping buffers. Instead of the above, I used:

    yypush_buffer_state(yy_create_buffer( yyin, YY_BUF_SIZE ));
    
    yypush_buffer_state(yy_scan_string(str));
    
    yypop_buffer_state();
    

    source:
    http://westes.github.io/flex/manual/Multiple-Input-Buffers.html

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

Sidebar

Related Questions

These days, I use Flex & Bison generated some codes to develop a SQL-parser
From the Bison Manual: In a simple interactive command parser where each input is
I'm using Flex and Bison for a parser generator, but having problems with the
I have created a small parser in c using flex and bison. The parser
There are many lexical analyzer and parser generators out there - lex/flex and yacc/bison,
I'm writing a Python parser to learn Flex and Bison, and I'm trying to
I have a mixed C/C++ program. It contains a flex/bison parser which targets C,
I'd like to use the same flex/bison scanner/parser for an interpreter and for loading
I have a parser generated using Flex/Bison - it parses each line of a
I am using Flex/Bison/C++ to evaluate an expression Here is a sample bison file

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.