What to do with lex output?

I have absolutely no background in compilers, and I started traveling "learn". I learn lex using this tutorial and typed something like this into a file calledfirst.l

%%
    /* match everything except newline */
.   ECHO;
    /* match newline */
\n ECHO;

%%

int yywrap(void) {
    return 1;
}

int main(void) {
    yylex();
    return 0;
}

Now I understand that lex should generate a tokenizer that will simply select everything it receives using the above file first.l. I went ahead and ran

lex first.l

Created a file with the name lex.yy.c. Then, the textbook provides several more examples and transitions to yacc. Can someone tell me what can be done with the file lex.yy.cthat lex creates? I thought I now have a tokenizer, but how do I now compile this file to a binary file? Using gcc?

+3
1

, GCC. , - :

gcc -c file1.c
gcc -c file2.c
gcc -o result file1.o file2.o

-c GCC , , . , , , gcc.

, , lex, :

gcc -o output lex.yy.c
+4

Source: https://habr.com/ru/post/1786826/


All Articles