Flex - PowerPoint PPT Presentation

1 / 3
About This Presentation
Title:

Flex

Description:

Edit the flex lexical analyzer file, structuring it according to rules ... Within a DOS Window. flex compiler.l. bison -y -d compiler.y. gcc -c lexyy.c y_tab.c ... – PowerPoint PPT presentation

Number of Views:132
Avg rating:3.0/5.0
Slides: 4
Provided by: johneb6
Category:
Tags: dos | flex

less

Transcript and Presenter's Notes

Title: Flex


1
Flex Bison
  • Compiler Generation Tools

2
Creating a Compiler with Flex and Bison
language.l (scanner description)
language.y (parser description)
Defines what to do with individual tokens or
sequences of tokens
Rules for recognizing tokens in the problem
y.out (state-machine description)
--verbose
flex
bison
--defines
lexyy.c yylex() (scanner)
yyout.c yyparse() (parser)
yyout.h (token definitions)
gcc C Compiler linker
Other libraries objects
flex-specific libraries (-lfl)
Generated Compiler
Input
Translated output
3
Compiler Generation Steps (GNU)
  • Edit the flex lexical analyzer file, structuring
    it according to rules for flex version 2.5.4
  • Edit the bison parser file(s), structuring it
    according to rules for bison version 1.25
  • must include a .c file
  • may include a .h file
  • Within a DOS Window
  • flex compiler.l
  • bison -y -d compiler.y
  • gcc -c lexyy.c y_tab.c
  • gcc -o compiler.exe lexyy.o y_tab.o -lfl
  • Now compiler.exe can be used to process input
    recognized by the grammar stored in the bison
    parser file according to rules specified in the
    flex lexical analyzer file.
Write a Comment
User Comments (0)
About PowerShow.com