Docsity

lexial analysis slides, Slides of Compilers

Partial preview of the text

Download lexial analysis slides and more Slides Compilers in PDF only on Docsity!

Lexical Analysis

Announcements

●

Programming Assignment 1 Out

●

Due Monday, July 9 at 11:59 PM.

●

Four handouts (all available online):

●

Decaf Specification

●

Lexical Analysis

● Intro to flex

●

Programming Assignment 1

while (ip < z)

++ip;

w h i l e ( i < z ) \n \t + i p ;

while (ip < z)

++ip;

p + +

w h i l e ( i < z ) \n \t + i p ;

while (ip < z)

++ip;

p + + T_While ( T_Ident < T_Ident ) ++ T_Ident ip z ip While ++ Ident < Ident Ident ip z ip

do[for] = new 0;

do[for] = new 0;

T_Do [ T_For T_New T_IntConst 0 d o [ f o r ] = n e w 0 ; ] =

do[for] = new 0;

T_Do [ T_For T_New T_IntConst 0 d o [ f o r ] = n e w 0 ; ] =

Scanning a Source File

w h i l e (( i 1 p 3 7 < < z )i \n) \t\n \t+ +++ i++ pi ;;

Scanning a Source File

w h i l e (( i 1 p 3 7 < < z )i \n) \t\n \t+ +++ i++ pi ;;

Scanning a Source File

w h i l e (( i 1 p 3 7 < < z )i \n) \t\n \t+ +++ i++ pi ;;

Scanning a Source File

w h i l e (( i 1 p 3 7 < < z )i \n) \t\n \t+ +++ i++ pi ;;

Scanning a Source File

w h i l e ( 1 3 < i ) \n \t + ++ i ; T_While

Scanning a Source File

w h i l e ( 1 3 < i ) \n \t + ++ i ; T_While

This is called a token. You can think of it as an enumerated type representing what logical entity we read out of the source code. This is called a token. You can think of it as an enumerated type representing what logical entity we read out of the source code. The piece of the original program from which we made the token is called a lexeme. The piece of the original program from which we made the token is called a lexeme.