LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Blogs > astrogeek
User Name
Password

Notices


Rate this Entry

A Simple Flex/Bison Project Template

Posted 08-19-2017 at 03:18 AM by astrogeek
Updated 08-19-2017 at 03:46 AM by astrogeek (typos)

For most of the past year I have encouraged others to make use of their LQ blog space as a place to post and manage code for their personal projects and interests which they wish to share with others.

Posting to our LQ blog space allows us to share our code and ideas without the posting constraints that apply within the question oriented fora, and also allows us to update, alter and extend that information over time without corrupting the logical development, or train of thought so important in the question and answer format fora.

It has long been my intent (far too long!) to lead by example by posting a few projects in a form that makes effective use of the LQ blog features to organize the information in a clear and accessible manner.

In that time I have started several drafts and example projects - but never found time to polish them up and post them here! My reasons and excuses have been many, including the various interruptions of life (reason) and the examples just weren't ready (mostly excuse).

I set myself the task of making the first such post, without fail, by the end of the current week. It is now long after midnight on Friday, and time is quickly running out, so for better or worse I have decided to begin by posting a simple Flex / Bison project template which I put together from notes collected from my own Flex / Bison projects.

The files posted here will allow you to build a working Flex lexer and Bison parser with location based error reporting, interactive and non-interactive modes, skeleton help feature, parser trace (debug) mode and more. The included features are listed in the README, and a simple Makefile with multiple useful targets is also included.

It intentionally defines only minimal tokens (but useful comment and quoted string examples), and a trivial single level grammar, the whole point being to put in place a working framework within which you may quickly get down to the business of defining your parser/compiler project by its grammar without much else to stumble over!

I have created a suitable local category hierarchy and organized the template project files below it into separate posts and indexed them below. The posts for each file also link back to this page as the top level page for the project, and include relevant links to the other project files. This makes for a simple to maintain but useful navigation scheme for the project files.

I have also included links to other relevant and valuable online resources below.

I hope that the the project template itself is useful, especially as a way for those new to Flex and Bison to get a working example running without some of the frustrations often experienced! This is not intended to be a Flex / Bison tutorial, so if you do not know what Flex and Bison provide for you, you will have to go read the manuals for the time being!

And of course, I hope this initial post can serve as an example of how we all can make better use of our LQ blog space to share our projects and ideas FREELY!

All code, descriptive text and errors are entirely my own - I give them freely and hope they are of some benefit! Thanks for reading!

Flex / Bison Template Files:

* README
* Bison source
* Flex source
* Makefile


Additional Reference Sources:

* Parsing Techniques: A Practical Guide, Dick Grune
The author has made the first edition available for free download through this page!
If you are new to parsing concepts, this is the place to start!

* Flex project home page

* GNU Bison project resources
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 02:41 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration