1 / 14

LL(1) Parser Generators

LL(1) Parser Generators. SLLGEN and JavaCC. class dictionaries (11 kinds). inductive. nonleft-recursive. 9. 10. 11. 8. 7. 6. 1. 2. LL(1). 3. 4. nonambiguous. 5. Venn Diagram. 11 kinds of class dictionaries. Why 11 and not 16?

rocio
Download Presentation

LL(1) Parser Generators

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. LL(1) Parser Generators SLLGEN and JavaCC PPL LL(1) Parser Generators

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

  3. 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 PPL LL(1) Parser Generators

  4. SLLGEN Error messages • What are the error messages you get from the SLLGEN Parser Generator if you violate any of the four properties? PPL LL(1) Parser Generators

  5. JavaCC Error messages • What are the error messages you get from the JavaCC Parser Generator if you violate any of the four properties? • Answers follow. PPL LL(1) Parser Generators

  6. Inductive class dictionaries • inductiveness already defined for class graphs • contains only good recursions: recursions that terminate Car = Motor. Motor = <belongsTo> Car. bad recursion, objects must be cyclic, cannot use for parsing: useless nonterminals PPL LL(1) Parser Generators

  7. Inductive class dictionaries • A node v in a class graph is inductive if there is at least one finite tree object of class v. • A class graph is inductive if all its nodes are inductive. Car = Motor Transmission. Motor = <belongsTo> Car. Transmission = . Which nodes are inductive? PPL LL(1) Parser Generators

  8. Inductiveness style rule to follow • Maximize the number of classes which are inductive. • Reasons: cyclic objects • cannot be parsed directly from sentences. • require visitors to break infinite loops. • it is harder to reason about cyclic objects. • No message from the Java Compiler Compiler! PPL LL(1) Parser Generators

  9. Left-recursive class dictionaries • Bring us back to the same class without consuming input. • Java Compiler Compiler: left recursion detected: A -> C -> A A : B | C. B = “b”. C = A. PPL LL(1) Parser Generators

  10. Ambiguous class dictionaries • cannot distinguish between objects. Print is not injective (one-to-one). Fruit : Apple | Orange. Apple = “a”. Orange = “a”. But: undecidable PPL LL(1) Parser Generators

  11. Java Compiler Compiler:error message • Warning: Choice conflict … A common prefix is “a”. Consider using a lookahead of 2 ... PPL LL(1) Parser Generators

  12. LL(1) class dictionaries • A special kind of nonambiguous class dictionaries. Membership can be checked efficiently. PPL LL(1) Parser Generators

  13. Java Compiler CompilerLL(1) error messages: Rule 2 • A = [B]. B = . • Error message: expansion can be mapped by empty string, line x, column y in Parser.jj. • A = [B] [“b” C]. B = “b”. C = . • Warning only: Choice conflict … line x column y. Expansion nested within construct and expansion following construct have common prefixes one of which is b. PPL LL(1) Parser Generators

  14. Style rule • Ideally, make your class dictionaries LL(1), nonleft-recursive and inductive. PPL LL(1) Parser Generators

More Related