1 / 68

Lexical Analysis

Lexical Analysis. Arial Font Family. Figure 3.1: Interactions between the lexical analyzer and the parser. Figure 3.2: Examples of tokens. Figure 3.3: Using a pair of input buffers. Figure 3.4: Sentinels at the end of each buffer. Figure 3.5: Lookahead code with sentinels.

celine
Télécharger la présentation

Lexical Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 algorithmtests whether string ala2 . . a, contains asingle keyword bl b2 . . . bnas 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 recognizingthe language of a regular expression

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

More Related