Debugging of Flex and Bison

Source: Internet
Author: User

  1. Official website and documentation (SourceForge I often encounter an inaccessible situation when using, do it yourself, you know)

      1. flex:http://flex.sourceforge.net/

        Document: http://flex.sourceforge.net/manual/

      2. bison:http://www.gnu.org/software/bison/

        Document: Https://www.gnu.org/software/bison/manual/html_node/index.html

      3. The versions I am currently using are: Flex 2.5.37, Bison 3.0.2, yum installation

  2. Debug parameters

    As you can see through--HELP, the Flex debug switch-d,bison the debug switch to-T, adding both parameters when generating the code.

  3. Manually adjust the Bison code, the light switch is not enough, open gram.c, you can see a lot of macro definitions inside are: "if (yydebug)", search "int yydebug;" definition to: "int yydebug = 1;" Another way is to set yydebug nonzero before starting the grammar engine in other files .

    See section: https://www.gnu.org/software/bison/manual/html_node/Tracing.html

  4. Scan.c bug fix, I could not compile the file in the version I used, error:

    1. in file included from gram.y:14877:0:scan.c: in function  ' Core_yylex ': scan.c:9263:47: error: macro  "fprintf"  requires 3 arguments, but only  2 given     fprintf ( stderr,  "--scanner backing up\n"  );                                                 ^scan.c:9263:5: warning:  statement with no effect [-wunused-value]     fprintf (  stderr,  "--scanner backing up\n"  );     ^scan.c:9266:52:  error: macro  "fprintf"  passed 4 arguments, but takes just 3                (long) yy_rule_linenum[yy_act], yytext );                                                       ^scan.c:9265:5:  warning: statement with no effect [-wunused-value]      fprintf ( stderr,  "--accepting rule at line %ld  (\"%s\ ") \ n",      ^ &NBSP, .....
    2. Open the SCAN.C Discovery macro definition:

        1. #undef fprintf#define fprintf (file, FMT, msg) fprintf_to_ereport (FMT, msg) static voidfprintf_to_ereport (const char *FMT , const char *msg) {ereport (ERROR, (Errmsg_internal ("%s", msg));}
    3. In conflict with the usage of fprintf below, comment out these lines



Debugging of Flex and Bison

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.