1 / 13

Class Dictionary

Class Dictionary. Jun Gong CCIS NEU SP 04. What is a class dictionary?. A special type of grammar. Describes the inheritance and the binary relation structure of your application. “=” and “:”. “has a” and “is a”. “~”, and “{}”. The list function. “[]” and “<>”. Example.

teddy
Download Presentation

Class Dictionary

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. Class Dictionary Jun Gong CCIS NEU SP 04

  2. What is a class dictionary? • A special type of grammar. • Describes the inheritance and the binary relation structure of your application. • “=” and “:”. “has a” and “is a”. • “~”, and “{}”. The list function. • “[]” and “<>”.

  3. Example • Basket = "basket" List(Thing) "end". • Thing : Fruit | Basket. • Fruit : Apple | Orange. • Apple = “apple” [<w> Weight]. • Orange = “orange” [<w> Weight]. • Weight = <i> int. • List(S) ~{S}.

  4. class dictionaries (11 kinds) inductive nonleft-recursive 9 10 11 8 7 6 1 2 LL(1) 3 4 nonambiguous 5 Venn Diagram

  5. 11 kinds of class dictionaries • Why 11 and not 16? • Four properties: nonambiguous, LL(1), inductive, non-left recursive: 16 sets if independent • But: implication relationships • LL(1) implies nonambiguous: 12 left • LL(1) and inductive imply nonleft-recursive: 11 left

  6. Nonambiguous • The definition. • Example: • Apple = “apple”. • Orange = “apple”.

  7. LL(1) • The definition. • Example 1: • Apple = Weight “apple”. • Orange = Weight “orange”. • Weight = int. • Example 1 revised: • Apple = “apple” Weight. • Orange = “orange” Weight. • Weight = int.

  8. Nonleft-recursive • Definition. • Directly left-recursive: • A = A “char”. • Indirectly left-recursive: • A1 = A2 “char1”. • A2 = A1 “char2”. • Left-recursion removal: • A = A B | B.  A = BP. P = B P | .

  9. Inductive • Definition. • Example 1: • Apple = “apple”. • Example 2: • ManyApples = Apple ManyApples. • Apple = “apple”. • Inductive  Good Recursive.

  10. What DemeterJ Wants • LL(1) • Nonleft-recursive • Inductive

  11. Parsing • Basket = "basket" List(Thing) "end". • Thing : Fruit | Basket. • Fruit : Apple | Orange. • Apple = "apple". • Orange = “orange”. • List(S) ~{S}.

  12. Basket {Apple, Basket} {Apple, Orange} Parsing Cont. • basket • apple • basket • apple • orange • end • end

  13. Basket Apple Basket Apple Orange Object Graph • : Basket ( • <thing_list> : Thing_List { • <first> : Nonempty_Thing_List ( • <it> : Apple ( ) • <next> : Nonempty_Thing_List ( • <it> : Basket ( • <thing_list> : Thing_List { • <first> : Nonempty_Thing_List ( • <it> : Apple ( ) • <next> : Nonempty_Thing_List ( • <it> : Orange ( ) ) ) } ) ) ) } )

More Related