Combine Lex, Yacc (Flex, Bison) is used with MFC!

xiaoxiao2021-03-06  39

Recently, I started using Lex and Bison to write some stuff, which is quite convenient to use it. After the core analysis of Lex, Bison, I would like everyone to embed them into my own project, and combine with other functions. However, there is often a lot of errors. LEX, Bison defaults are C's source, and both have their own grammar rules. Sometimes there is some conflict with the VC, but these problems can be solved as long as the part definition is modified. 1, YYERROR () function, this function can write directly in the YACC file. However, in the VC needs to be pre-declared, that is to say that the yyrror () declaration portion must be placed in the first part of the YACC file. 2, isatty () function, no attention to this stuff, Lex, Bison generated, running at all, but after adding MFC, this function suddenly jumped out, saying that it is not defined. The result had to go in Y, INCLUDE. What is the reason, I am not very clear. 3, data exchange problem. LEX, YACC default input is the keyboard. So create a new buffer for Lex. Here you can create a new file as a buffer, or you can use a string yy_switch_to_buffer (yy_scan_string (m_stredit.getbuffth))))))))))))))))))); the output of the result can be used with a global string. This can basically use Lex in the MFC, Bison brings us convenience. The above is my own little bit of experience, the mistakes and improper things are inevitable, laugh!

转载请注明原文地址:https://www.9cbs.com/read-77267.html

New Post(0)