




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































Regular Expressions to NFA NFA to DFA
Scan Input Remove WS, NL, … Identify Tokens Create Symbol Table Insert Tokens into ST Generate Errors Send Tokens to Parser
Perform Syntax Analysis Actions Dictated by Token Order Update Symbol Table Entries Create Abstract Rep. of Source Generate Errors And More…. (We’ll see later)
A classification for a common set of strings Examples Include Identifier, Integer, Float, Assign, LParen, RParen, etc. PATTERN The rules which characterize the set of strings for a token – integers [0-9]+ Recall File and OS Wildcards ([A-Z].) LEXEME Actual sequence of characters that matches pattern and is classified by a token Identifiers: x, count, name, etc… Integers: 345, 20 - 12, etc. Docsity.com
Token Sample Lexemes Informal Description of Pattern const
if
relation
id
num
literal
const if <, <=, =, < >, >, >= pi, count, D 3.1416, 0, 6.02E “core dumped”
const if < or <= or = or < > or >= or > letter followed by letters and digits any numeric constant any characters between “ and “ except “
Classifies Pattern
Actual values are critical. Info is :
Lexical Analyzer Generator Hand-Code / High Level Language (I/O facilitated by the language) Hand-Code / Assembly Language (explicitly manage I/O).
Regular Context Free Context Sensitive Natural
Asynchronous I/O - for 1 block While Lexical Analysis on 2nd block
Block 1 Block 2
When done, ptr... issue I/O Still Process tokenin 2nd block
ALPHABET : Finite set of symbols {0,1}, or {a,b,c}, or {n,m, … , z}
STRING : Finite sequence of symbols from an alphabet. 0011 or abbca or AABBC … A.K.A. word / sentence
If S is a string, then |S| is the length of S, i.e. the number of symbols in the string S. ∈ : Empty String, with | ∈ | = 0
Suppose: S is the string banana
Prefix : ban, banana Suffix : ana, banana Substring : nan, ban, ana, banana Subsequence: bnan, nn
Proper prefix, suffix, or substring cannot be all of S
OPERATION DEFINITION
union of L and M written L ∪ M concatenation o f L and M written LM Kleene closure of L written L*
positive closure of L written L+
L ∪ M = {s | s is in L or s is in M}
LM = {st | s is in L and t is in M}
L+=
∞ i = 0
Li L denotes “zero or more concatenations of “ L*
L=*
∞ i = 1 Li L+^ denotes “one or more concatenations of “ L
L = { All possible strings of L plus* ∈ }
L+^ = L -* ∈
L (L ∪ D ) = ??
L (L ∪ D ) = ??*