PLT: Lecture 9 - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

PLT: Lecture 9

Description:

The lousy dirty rotten swine took my drink. Try to make a Context Free Grammar out of it; ... RestOfStuff - lousy RestOfStuff RestOfStuff - dirty RestOfStuff ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 10
Provided by: deptSc7
Category:
Tags: plt | lecture | lousy

less

Transcript and Presenter's Notes

Title: PLT: Lecture 9


1
PLT Lecture 9
  • Classifying Grammars and Parsing

2
Classifying Grammars
  • Unrestricted Grammars
  • a -gt b
  • Otherwise no restrictions
  • Context Sensitive Grammars
  • a -gt b
  • a !gt b
  • Context Free Grammars
  • A-gt b
  • Regular Grammars
  • A-gtaB
  • A-gta

3
The Drunkards Lament
  • Instances
  • Some dirty swine stole my drink
  • A pig stole my drink
  • A lousy rat took my drink
  • A rotten lousy dirty rat swiped my drink
  • The lousy dirty rotten swine took my drink
  • Try to make a Context Free Grammar out of it
  • Try to make a Regular Grammar out of it.

4
Drunkards Lament CF Grammar
  • ltLamentgt-gt ltArticlegtltAdjstuffgtltNoungtltVerbgt my
    drink
  • ltArticlegt-gtSome A The
  • ltAdjstuffgt-gtltAdjgtltAdjstuffgt
  • ltAdjstuffgt-gtltAdjgt
  • ltAdjstuffgt-gt l
  • ltAdjgt-gt rotton lousy dirty
  • ltNoungt-gt swine pig rat
  • ltVerbgt-gt took swiped stole

5
Drunkards Lament Regular Grammar
  • ltLamentgt-gt Some ltRestOfStuffgt
  • ltLamentgt-gt A ltRestOfStuffgt
  • ltLamentgt-gt The ltRestOfStuffgt
  • ltRestOfStuffgt-gtrotton ltRestOfStuffgt
  • ltRestOfStuffgt-gtlousy ltRestOfStuffgt
  • ltRestOfStuffgt-gtdirty ltRestOfStuffgt
  • ltRestOfStuffgt-gtswine ltVerbObjectgt
  • ltRestOfStuffgt-gtpig ltVerbObjectgt
  • ltRestOfStuffgt-gtrat ltVerbObjectgt
  • ltVerbObjectgt-gttook ltObjectgt
  • ltVerbObjectgt-gtswiped ltObjectgt
  • ltVerbObjectgt-gtstole ltObjectgt
  • ltObjectgt-gt my ltDrinkWordgt
  • ltDrinkwordgt-gt drink

6
From Generating To Parsing
  • So far, generative
  • Now parsing
  • Can we move, using the production rules, from the
    start symbol to the language instance
  • Can we apply the production rules in reverse to
    work back up to the start symbol from the
    language instance
  • If we establish at least 1 sequence of
    application of production rules
  • If we prove we cant establish a sequence of
    application of production rules

7
A Simple Started E.G.
  • Start Symbol
  • E
  • Production Rules
  • E-gtET
  • E-gtT
  • T-gtTF
  • T-gtF
  • F-gt(E)
  • F-gta
  • Possible Parses 3
  • Summation by Parse Tree

8
Top-Down parsing
  • Start at the start symbol
  • Leftmost derivation
  • Rightmost derivation
  • If unambiguous parse tree, then a successful
    top-down parse can be fully specified by
  • The parse tree
  • Specifying the strategy
  • Specifying the production rules
  • The need for an automaton
  • Top-Down parsing
  • Bottom-up parsing

9
CFGs and Mathematical Characteristics
  • Can we impose some semantic knowledge in the
    grammar?
  • Priority
  • Check our example
  • Associate a VN with each priority
  • N VN with ops of priority P
  • N VN with ops of priority P
  • P is 1 priority greater than P
  • N-gtNo1N
  • N-gtNo2N
  • .
  • N-gtN
Write a Comment
User Comments (0)
About PowerShow.com