Abstract
in the process of developing the program often encounter text parsing problems, such as: parsing the C language source program,scripting engine and so on, there are many ways to solve this kind of text parsing, one way is to manuallywrite the parser directly in C or C + +, which is not what it is for a simple format text messageproblem, but for the resolution of slightly more complex textual information, the manual parser will be a long, painful and error-prone thing. This series of documents is specifically designed to introduce the two well- known Unix tools Lex and YACC, and will step by step explain how to use these two tools to implement any function we want the parser, in order to facilitate understanding and application , I will use practical examples as much as possible in this series of articles to illustrate, and this instance is as relevant as possible to the specific system platform, so I use command-line procedures as the final result of our parser .
1 Environment Configuration Chapter 1.1 Prerequisites (Note: The required tools are available in my resources file)
Programs that are required to be installed by the Lex and YACC development environment under the Windows platform:
(1) Lex (Flex.exe)
(2) YACC (Bison.exe)
(3) C + + compiler
1.2 Flex and Bison installation
Flex.exe and Bison.exe are files in the Unxutils package, and manyUnix/ Linux platform programs are ported to the Windows platform and can be directly unxutils website Download , After the download decompression in the system's PATH environment variable to add unxutils all EXE files are located recorded, so that the DOS command line can be directly searched for Flex.exe and Bison.exe, in addition to download bison required bison.simple and bison.hairy two files on the network, and also Set environment variable Bison_hairy point to Bison.hairy,bison_simple point to Bison.simple.
< Span style= "font-family:; font-size:12pt; Color:rgb (0,0,0); Font-style:normal; Font-variant:normal "> /span>
< Span style= "font-family:; font-size:12pt; Color:rgb (0,0,0); Font-style:normal; Font-variant:normal "> and then, Open Cmd check
< Span style= "font-family:; font-size:12pt; Color:rgb (0,0,0); Font-style:normal; Font-variant:normal ">
1.3/C + + compiler
The Flex and Bison we use are GNU's tools, so for convenience, the C + + compiler that is used is also the GNU compiler, GCC, which requires the Windows version of the MinGW compiler to download the installation on the home page of MinGW .
after the installation is complete, the bin under the MinGW The directory is added to the path of the system environment variable.
Configuration is complete.
Lex and Yacc Learning (a) Environment configuration section