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.