I create an .exe FILE, which can parser an expression, which is generated by lex and yacc. But I do it just get the input from screen, and just return the parser result from screen. I saw some suggestions about using YY_BUFFER_STATE yy_scan_buffer(char *base, yy_size_t size)
, but I still could not find a good way to do it.
Is it possible that I put some headers (which is compiled by lex yacc) to my main program c++, and then I can use yylex() to call it, giving a string as input, and get the return value in the main program? Thanks for your help, I am confused about how to realize it. Thanks.
gnu-flex
tag is for GNU Flex. – Jonathan Leffler.exe
) from the Lex and Yacc code, then you aren't going to be able to use it as a subroutine in a C++ program, so I'm confused about that part of your question. If you're asking whether you can organize a lexical scanner so that instead of reading from standard input, it will read from a string, the answer is 'yes, but how depends on whether you're using AT&T Lex or GNU Flex or some other variant of Lex'. Please clarify. – Jonathan Leffler