Configure YACC and Lex development environment in Windows (Parser Generator)

Source: Internet
Author: User
  1. Download and install
    Parser Generator is the implementation of YACC and Lex in windows and is developed by bumble-bee software.
    Http://www.bumblebeesoftware.com/downloads.htm.
    After installing the software, set the path of the system environment variable and add the installation bin directory in the path attribute. Take my installation as an example and add it after the previous path attribute. D: /program files/Parser Generator 2/bin
    In the Console Command window, enter Alex and ayacc to check whether the two commands can be found. If the two commands cannot be found, the environment variable settings must be incorrect.
  2. Vc.net Configuration
    The following uses vc.net as an example to describe the configuration.
    1) Open the vc.net program, open the menu "Tools" => "options", and open the "options" dialog box.
    2) Select "Projects" => "VC ++ directory" on the left of the Options dialog box"
    In the directory where the following content is displayed (S) "Select" executable files "from the drop-down list and add a line" D:/program files/Parser Generator 2/bin "to the directory list below"
    In the directory where the following content is displayed (S) "Select" include files "from the drop-down list and add a line to the directory list below:" D:/program files/Parser Generator 2/CPP/include"
    In the directory where the following content is displayed (S) "Select" library files "from the drop-down list and add a line to the directory list below:" D:/program files/Parser Generator 2/CPP/lib/msvc32"
    In the directory where the following content is displayed (S) "Select" source file "from the drop-down list and add a line to the directory list below." D:/program files/Parser Generator 2/CPP/source"
  3. Example
    Use vc.net to create a console Project
    Select a project, right-click the project, and select "properties" from the shortcut menu. Alternatively, select "project" => "properties" from the shortcut menu to open the Project Properties dialog box.
    1) Select "attribute configuration" => "C/C ++" => "preprocessing" on the left. In the list on the right, add a yydebug macro definition in the pre-processor definition line, which is separated by a; number by another macro definition.
    2) Select "Property configuration" => "connector" => "input" on the left, and add YLD to "add dependency" in the list on the right. lib or ylmtrid. lib (ylmtrid. lib is multi-thread, YLD. lib is a single thread)
    3) Copy calc from the D:/program files/Parser Generator 2/CPP/examples/calc directory. Y file to the project directory, open the console, enter the project Calc. run the command ayacc Calc. y. If it succeeds, you will see a calc. c file generation. set Calc. C is added to the project, and then compiled to generate executable programs.
    4) configure the compilation option to automatically convert the. Y. l file.
    Select. Y file, right-click the menu => "properties" to open the Properties dialog box, select "Custom generation step" in the Properties dialog box, and enter ayacc Calc. y, input calc in "output. c; in this way, you can compile the project according to calc. the y file automatically generates Calc. c file ,. l file generation and configuration methods are similar.
  4. End
    I have successfully generated a program according to the above steps, without any errors. The configuration of vc6.0 is similar. If there is anything wrong, please correct me.
    In addition, you can use cygwin, read the article http://hi.baidu.com/momoca/blog/item/f6010cd7dbdb00dea044df51.html
    Can also use mingw, read the article http://hi.baidu.com/dadandachan/blog/item/449d802f0ff9b1381e3089b0.html
    Flex, Bison http://www.monmouth.com /~ Wstreett/Lex-YACC/lex-yacc.html
    Cygwin and mingw are no longer giving examples here. You can refer to the above article as a tool.
    YACC & Lex English document http://www.cs.man.ac.uk /~ PJJ/cs2111/
    Http://epaperpress.com/lexandyacc/
    Http://yaxx.sourceforge.net
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.