Menu

Some questions

Nasi
2014-10-25
2014-10-27
  • Nasi

    Nasi - 2014-10-25

    Thanks for your good article. I have three questions:

    1- Why doesn't "win_flex bison" generate "lexer.tab.h" file? It only generates three files.
    2- I want to set a break point in generated C file, but it's not possible. How to do this?
    3- I want to generate C++ file. Is there any way to generate C++ parser CLASS by "win_flex bison"?

    Thanks in advance

     
  • Alex Zhondin

    Alex Zhondin - 2014-10-26

    Hi Nasi!

    Thank you for your review and rating of winflexbison.

    To learn flex/bison your can read documentation flex_bison_doc.zip or google your questions in the internet (fastest way).

    1. Q: Why doesn't "win_flex bison" generate "lexer.tab.h" file? It only generates three files.
      A: About bison.tab.h file you can read in bison.pdf page 153 from zip archive. Usually this header file is used to connect flex and bison code. Flex.l file includes bison.tab.h to use the same tokens that were defined in bison.y

    2- Q: I want to set a break point in generated C file, but it's not possible. How to do this?
    A: You can set break point in .l and .y files. #line directives in generated .h/.cpp files instruct C++ compiler and debugger where to find original code (within .l/.y files). I've updated an article.
    This is new picture to demonstrate debugging:
    Flex debugging

    3- Q: I want to generate C++ file. Is there any way to generate C++ parser CLASS by "win_flex bison"?
    A: See Chapter "10.1 C++ Parsers" in bison.pdf page 157 and Chapter "18 Generating C++ Scanners" in flex.pdf page 57. Also you can take a look here

    Best regards,
    Alex

     
  • Nasi

    Nasi - 2014-10-27

    Thanks for your answers.

    About Question 1: I know about bison.tab.h. My Question is about flex.tab.h that wasn't generated. I want to generate flex.tab.h. After generating of this file, bison.y can include flex.tab.h to use some functions and typedefs that were defined in flex.l, such as yy_scan_string and yyscan_t. How to do this?

    Bests,
    Nasi

     
  • Alex Zhondin

    Alex Zhondin - 2014-10-27

    I think you are looking for %option header-file="FILE" option. You can find description in flex.pdf file page 43.
    Here is a quote from there:

    ‘--header-file=FILE, %option header-file="FILE"’
    instructs flex to write a C header to ‘FILE’. This file contains function prototypes,
    extern variables, and types used by the scanner. Only the external
    API is exported by the header file. Many macros that are usable from within
    scanner actions are not exported to the header file. This is due to namespace
    problems and the goal of a clean external API.
    While in the header, the macro yyIN_HEADER is defined, where ‘yy’ is substituted
    with the appropriate prefix.
    The ‘--header-file’ option is not compatible with the ‘--c++’ option, since
    the C++ scanner provides its own header in ‘yyFlexLexer.h’.

     

Log in to post a comment.