Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lexical Analysis Arial Font Family.

Similar presentations


Presentation on theme: "Lexical Analysis Arial Font Family."— Presentation transcript:

1 Lexical Analysis Arial Font Family

2 Figure 3.1: Interactions between the lexical analyzer and the parser

3 Figure 3.2: Examples of tokens

4 Figure 3.3: Using a pair of input buffers

5 Figure 3.4: Sentinels at the end of each buffer

6 Figure 3.5: Lookahead code with sentinels

7 Figure 3.6: Definitions of operations on languages

8 Figure 3.7: Algebraic laws for regular expressions

9 Figure 3.8: Lex regular expressions

10 Figure 3.9: Filename expressions used by the shell command sh

11 Figure 3.10: A grammar for branching statements

12 Figure 3.11: Patterns for tokens of Example 3.8

13 Figure 3.12: Tokens, their patterns, and attribute values

14 Figure 3.13: Transition diagram for relop

15 Figure 3.14: A transition diagram for id's and keywords

16 Figure 3.15: Hypothetical transition diagram for the keyword then

17 Figure 3.16: A transition diagram for unsigned numbers

18 Figure 3.17: A transition diagram for whitespace

19 Figure 3.18: Sketch of implementation of relop transition diagram

20 Figure 3.19: Algorithm to compute the failure function for keyword blb2 . . . bn

21 Figure 3. 20: The KMP algorithm tests whether string ala2
Figure 3.20: The KMP algorithm tests whether string ala2 . . a, contains a single keyword bl b bn as a substring in O(m + n) time

22 Figure 3.21: Trie for keywords he, she, his, hers

23 Figure 3.22: Creating a lexical analyzer with Lex

24 Figure 3.23: Lex program for the tokens of Fig. 3.12

25 Figure 3.24: A nondeterministic finite automaton

26 Figure 3.25: Transition table for the NFA of Fig. 3.24

27 Figure 3.26: NFA accepting aa* 1 bb*

28 Figure 3.27: Simulating a DFA

29 Figure 3.28: DFA accepting (aJb)*abb

30 Figure 3.29: NFA for Exercise 3.6.3

31 Figure 3.30: NFA for Exercise 3.6.4

32 Figure 3.31: Operations on NFA states

33 Figure 3.32: The subset construction

34 Figure 3.33: Computing E- closure(T)

35 Figure 3.34: NFA N for (alb)*abb

36 Figure 3.35: Transition table Dtran for DFA D

37 Figure 3.36: Result of applying the subset construction to Fig. 3.34

38 Figure 3.37: Simulating an NFA

39 Figure 3.38: Adding a new state s, which is known not to be on newstates

40 Figure 3.39: Implementation of step (4) of Fig. 3.37

41 Figure 3.40: NFA for the union of two regular expressions

42 Figure 3.41: NFA for the concatenation of two regular expressions

43 Figure 3.42: NFA for the closure of a regular expression

44 Figure 3.43: Parse tree for (alb)*abb

45 Figure 3.44: NFA for r3

46 Figure 3.45: NFA for r5

47 Figure 3.46: NFA for r

48 Figure 3.47: An NFA that has many fewer states than the smallest equivalent DFA

49 Figure 3.48: Initial cost and per-string-cost of various methods of recognizing the language of a regular expression

50 Figure 3.49: A Lex program is turned into a transition table and actions, which are used by a finite-automaton simulator

51 Figure 3.50: An NFA constructed from a Lex program

52 Figure 3.51: NFA's for a, abb, and a*b+

53 Figure 3.52: Combined NFA

54 Figure 3.53: Sequence of sets of states entered when processing input aaba

55 Figure 3.54: Transition graph for DFA handling the patterns a, abb, and a*b+

56 Figure 3.55: NFA recognizing the keyword IF

57 Figure 3.56: Syntax tree for (aJb)*abb#

58 Figure 3.57: NFA constructed by Algorithm 3.23 for (a(b)*abb#

59 Figure 3.58: Rules for computing nullable and firstpos

60 Figure 3.59: firstpos and lastpos for nodes in the syntax tree for (alb)*abb#

61 Figure 3.60: The function followpos

62 Figure 3.61: Directed graph for the function followpos

63 Figure 3.62: Construction of a DFA directly from a regular expression

64 Figure 3.63: DFA constructed from Fig. 3.57

65 Figure 3.64: Construction of Π new

66 Figure 3.65: Transition table of minimum-state DFA

67 Figure 3.66: Data structure for representing transition tables

68 Terima Kasih


Download ppt "Lexical Analysis Arial Font Family."

Similar presentations


Ads by Google