Я совершенно новичок во флексе.
Я получаю сообщение об ошибке сборки при использовании flex. То есть я создал файл .c, используя flex, и при его запуске получаю эту ошибку:
1>lextest.obj : error LNK2001: unresolved external symbol "int __cdecl isatty(int)" (?isatty@@YAHH@Z)
1>C:\...\lextest.exe : fatal error LNK1120: 1 unresolved externals
вот файл lex, который я использую (взято из здесь):
/*** Definition section ***/
%{
/* C code to be copied verbatim */
#include <stdio.h>
%}
/* This tells flex to read only one input file */
%option noyywrap
%%
/*** Rules section ***/
/* [0-9]+ matches a string of one or more digits */
[0-9]+ {
/* yytext is a string containing the matched text. */
printf("Saw an integer: %s\n", yytext);
}
. { /* Ignore all other characters. */ }
%%
/*** C Code section ***/
int main(void)
{
/* Call the lexer, then quit. */
yylex();
return 0;
}
Кроме того, почему я должен помещать «основную» функцию в код синтаксиса lex? Я хотел бы иметь возможность вызывать yylex(); из другого файла c.