Flex & Bison rules to be noted

Source: Internet
Author: User

1. the binary mode of flex

  • The syntax analyzer matches as many strings as possible during input.
  • If both modes can be matched, match the earlier mode in the program.

    In terms of understanding this, in the syntax analysis file, token recognition, it should be written in special to general procedures (in order to add logs to print the currently split token for debugging), for example, in the process of implementing syntax analysis, when the lexical split column is not null, the null lexical should be written to the front end of the identifier recognition. Otherwise, the null is first split into identifer rather than the null final delimiter.

    Null {
    Malloc_node (yylval-> node, (parseresult *) yyextra)-> memorypool, t_null, 0 );
    Return nullx;
    }

    {Identifer }{
    Int ret = Name;
    Astnode * node = NULL;
    Malloc_node (node, (parseresult *) yyextra)-> memorypool, t_name, 0 );
    ....
    }

2. in the syntax analysis file, The Terminator defined by % token and the non-terminator defined by % type do not need to be manually declared through enum. the bison tool automatically analyzes the definitions in the syntax analysis file, the corresponding yytokentype definition is automatically generated.

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.