473,416 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

Clearing parser state of a bison generated parser

Iam using c lexer that is flex generated and a c++ parser that is bison generated. i have modified the parser to acccept only string input.
I am calling the parser function yyparse in a loop and reading line by line of user input. I stop the loop if the input is "quit".

The problem i am facing is that when input does'nt match any rule then, the parser stops abruptly, and at next iteration starts off
at same state, expecting the rule which was stopped (due to synatx error )to complete.
It works fine if the input is valid and matches a parser rule.
On syntax error i have redefined the yyerror function, that displays a simple error message.

How do i clear the state of the parser when the input does'nt match any parser rule, and at next iteration the parser starts afresh.
Oct 21 '08 #1
0 1328

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

Similar topics

12
by: pmatos | last post by:
Hi all, I need to create a parser in C++ which should parse a somewhat complex file structure. Yeah, it would be possible to write it from scratch in C++ however I think it would be easier and...
9
by: Cesar A. K. Grossmann | last post by:
Hi I'm trying to build a parser for a file I create. The file format is as follow: IDENTIFIER = NUMBER STRING STRING; COMPOSITE = STRING { ITEM }; ITEM = NUMBER IDENTIFIER|COMPOSITE
9
by: Jonas Geiregat | last post by:
I'm trying to parse a configuration file, this is the first time I'm trying something like this, and it seems hard. C's I/O functions are a mess and hard to use , that is if you want to write code...
3
by: John Sasso | last post by:
In my Yacc .y file I defined: %union { int value; struct Symbol Sym; } The Symbol struct I defined in a header file I #included in the Prologue section of the .y file as:
6
by: Mike C# | last post by:
Hi all, Can anyone recommend a good and *easy to use* lexer and parser generator? Preferably one that was written specifically for VC++ and not mangled through 20 different platforms. I've had...
13
by: jc | last post by:
I have written a parser using bison and flex to read ASAP2 file for CAN communications. entire development was done in an unix environment and now the code is ready to be integrated to an existing...
1
by: Peter Ammon | last post by:
I was watching a video about a new C front end for the LLVM C compiler (on youtube, of all places), and the author made an interesting claim: that writing a C preprocessor is much harder, and...
1
by: cwhite | last post by:
Hi! I've included some of my classes in the union in my grammar file: %union { int int_type; char* string_type; PNode* pNode; } %type <int_type> programs %type <pNode> program
5
by: Antoninus Twink | last post by:
On 19 Jun 2008 at 21:27, vaib wrote: Check out yacc (aka bison).
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.