CS 441G
FSA for Pascal Lexemes
– This FSA is used to extract the next lexeme from the source file; not to validate the entire source at once.
– Drawn as separate FSAs for the sake of convenience, the following diagrams are all one FSA. States repeated on multiple diagrams that are actually the same state are:
o Start
o Halt–withmeaningthatnoerrorwasdetectedandavalidlexemewasfound o ERR–withmeaningthatanerrorwasdetected.
– Character Categories Used:
o o #
o W o eol o eof o
o
alphabetics (a..z, A..Z)
digits (0..9)
white space (space, tab).
end of line (newline/line feed, carriage return) – end of file
– unambiguous single-character symbols: +-/[],;^()
– special symbol indicating “any other valid character not designated on an out arrow of this state.”
– Actions: what to do with the character read:
o Add To Current Lexeme (default: not indicated in the diagrams) o
o
– Put Back (P in a diamond symbol)
– Look Ahead:
o LA = x x is the look ahead character category o Default any;notindicatedondiagram
Comments, Leading Whitespace, and EOF:
(no Lexeme found; Halt only on EOF)
Identifiers:
Numeric Literals:
String Literals:
Symbols/Operators:
Reviews
There are no reviews yet.