Академический Документы
Профессиональный Документы
Культура Документы
Errors
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
if state ∈ SF se se se se
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
1
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
• Output: matching
patterns
semantic
actions
FA
input buffer
– Generates a C function named yylex in the file lex.yy.c,
output file
simulator
with the command lex file.l and compiled using -ll switch
– flex uses the library -lfl
Transition
Table
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
2
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
• FILE *yyin, file pointer where from the input characters are read • void yymore(void), function invoked in a semantic action allowing the
matched text to be saved and concatenated to the following matched text
• FILE *yyout, file pointer where to the output text is written using the
ECHO macro or other programmer defined functions • void yyless(int n), function invoked in a semantic action allowing the n
characters of yytext to be reconsidered for processing.
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
3
CSCI 565 - Compiler Design Spring 2010 CSCI 565 - Compiler Design Spring 2010
Summary
• Scanner Construction
– Table-driven
– Direct-coded
Pedro Diniz 21
pedro@isi.edu