Downloads

How to Use Bison & Flex
to Implement Scripting Language

gallery/backgr2

my Experience with Bison and Flex

 

My first contact with Bison and Flex goes back to 2004. When I first taught myself C++ language programming back in in 1990, I wished I could be able to create a programming language like C++ some day by myself. I have used C++ language after since 1990, and C++ language has been my only programming language. I never liked Java or any other programming language but C++. 

 

From 2004 until 2008, I developed a complete scripting language called Yet Another Language using Bison and Flex. At that time I used Bison 2.54. After since 2008, I have not used Bison or Flex much... for I developed another kind of software that does not need scripting feature. Now I come back to numerical computing and need of these tools, Bison and Flex. Many things have changed since then. I have to read the manuals again.

 

Through this web space, I want to make a complete Bison and Flex tutorials with both easy-to-understand documentation and easy-to-follow YouTube videos. Note that English is not my mother tongue, and I learned it  only through book reading such that my English pronunciation is horribly bad and hard to understand. However, I will do my best to delivery easy-to-follow YouTube videos along with detailed documentations that are not included in the official Bison and Flex manuals... Also I will unsparingly share my know-hows about scripting language development. 

 

00A. Installing Bison and Flex - The Easy Way

 

If you are using Bison and Flex for the first time in your life, installing Bison and Flex is rather challenging and even a bit frustrating. Some cool guy ported GNU Bison and Flex for Windows platform. Click here if you want to visit his website. As of this writing, Feb. 17, 2017, the latest version is win_flex_bison-2.5.9.zip. Please watch my YouTube video about installing win_flex_bison for use with Visual Studio. You need to download this package to install win_flex_bison to follow my tutorial video. Google chrome falsely alram about this download, if you are unsure, please verify your download using WinMD. You can also download my Powerpoint presentation about how to make settings in Visual Studio.

 

                MD Code:  0b83403959ffdbe31905d1e7344a322b

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(The Easy Way to Install Bison and Flex on Windows)

 

 

00B. Installing Bison and Flex - the Harder Way

 

As of Feb. 17, 2017, we will use Visual Studio 2015 with Update 3. You can create C++ programs using Visual Studio Community Edition, but I strongly recommend you to use Visual Studio Professional version or above. In my case, I use Visual Studio Enterprise. If you never installed Visual Studio by yourself before, please watch my YouTube video about How to Install Visual Studio 2015o . We will use Bison 3.0.4 and Flex 2.6.3. We need to install Cygwin to compile Bison and Flex by ourselves. Please watch How to Build, Install Bison, Flex, Cygwin on Windows. It might be might be challenging, but quite rewarding in the long run. You can download detailed manuscript for installation of Cygwin, bison, flex, and Powerpoint presentation.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(For Diehard Way to Install Bison and Flex on Windows)

 

001. Our first Bison & Flex Program

 

If we successfully installed Bison and Flex on the machine, we can get started with our first Bison and Flex program. I will assume we are creating our program first time in our life using Bison and Flex. This step is most challenging, but also breathtakingly exciting and exhilarating. I would be greatly honored if you feel the same. Now watch this our first Bison & Flex video.

 

  1. Click here to download tutorial source code.
  2. You can get detail explanation document at this link.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

After watching this video, you may feel either "wow it's challenging but I will make it anyway" or "OMG, it's too difficult, I can't understand anything!" Don't get disheartened or discouraged yet! There is always easier ways. You will find it not that challenging if you keep watching my next video.

 

002. Three Different Ways to Install Bison and Flex

 

This video summarizes three different ways to install bison and flex on windows.

 

 

 

 

 

 

 

 

 

 

 

 

 

003. Re-entrant Parser and Lexer

 

If you are learning Bison and Flex for the first time, I would recommend you to take the right course. After learning basics, delve into more advanced concept. Reentrant parser and lexer are very important if you succeed in software development in the long run. Download the sample code and watch the video below:

 

MD5 code:  83a0fa53b1ad0721cafacdc85b53954d

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(Placeholder for video to come)

 

004A. GNU Bison and Flex with MSYS2

 

If you are diehard UNIX or LINUX developer and want to learn bison and flex on Windows platform, then this is the tutorial video for you, about how to install Bison and Flex included in MSYS2 package.

 

Please watch this video.

 

 

 

004B. Scan UNICODE (UTF-16) String Instead of Console/File Input with Flex

 

Please watch this video to learn how to use string buffer instead of file input.

 

Download Flex Regular Expressions for Unicode Text

MD5: f410ff01cea6cb6a0b24cef7c5198110

 

 

004C. Hosting Windows Form in MFC Application

 

Please watch this video to learn how to host Windows Form control in MFC Application.

 

Download sample source code.

MD5 code: 481fe4f6163d490a4199f3667929d2d4

 

 

004D. Create Excel Like Spreadsheet using Bison and Flex

 

Download sample source code I prepared before taping YouTube video 

MD5 code: 9304572f2a4d94268d5c503a64af11cf

Download sample source code while taping YouTube video.

MD5 code: 0de8b5b59e6e6cc7d7eb5a2b59fc773f

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

005. Get Input From ANSI File

 

Please watch this video to learn how to get flex input from ANSI text file.

 

Download source code.

 

 

006. How to Implement Stack Data Structure

 

Stack data structure is a must-have to implement a scripting language. Please watch this video to learn how to implement stack data structure.

 

Download sample source code.

 

 

007. Bison & Flex Fundamentals - Non-reentrant (Theory 1)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

008. Passing Parameters to yyparse() and yylex() 

 

This video explains how to pass parameters to yylex() and yyparse().

For more information, please this documents.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

009. Tracking Locations with Bison and Flex

 

 

010. CRT and MFC Memory Leak Detection

 

  1. Download the sample source code.
  2. CRT Debug Heap Details (MSND) (PDF)
  3. Finding Memory Leaks Using the CRT Library (MSDN) (PDF)
  4. MFC Debugging Techniques (MSDN) (PDF)
  5. Please watch this video.

 

011. Memory Leak Detection Class

 

  1. Download full sample source code.
  2. Download the header file, memory_leak_detect.h
  3. Watch this video.

 

12. Multiple Scanners and Parsers in the Same Project

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

013. Exception-Safe in C++ Programming

 

The primary cause of resource (or memory) leak in C++ programming is "exception unsafe" coding practice. If you write your codes in an exception-safe manner, you can reduce more than 60 to 70% of the dreadful resource leak in your C++ programs.

 

Download the sample source code.

 

 

 

 

 

 

 

 

 

 

 

 

 

gallery/01
gallery/03
gallery/02