LL1 Parser Generators SLLGEN and Java CC 1072020












![Java Compiler LL(1) error messages: Rule 2 • A = [B]. B =. – Java Compiler LL(1) error messages: Rule 2 • A = [B]. B =. –](https://slidetodoc.com/presentation_image/f276b9e290d7193942edbfd11f31d91a/image-13.jpg)

- Slides: 14
LL(1) Parser Generators SLLGEN and Java. CC 10/7/2020 PPL LL(1) Parser Generators 1
class dictionaries (11 kinds) inductive nonleft-recursive 10 9 11 8 7 6 2 1 LL(1) 3 4 5 10/7/2020 nonambiguous PPL LL(1) Parser Generators Venn Diagram 2
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 10/7/2020 PPL LL(1) Parser Generators 3
SLLGEN Error messages • What are the error messages you get from the SLLGEN Parser Generator if you violate any of the four properties? 10/7/2020 PPL LL(1) Parser Generators 4
Java. CC Error messages • What are the error messages you get from the Java. CC Parser Generator if you violate any of the four properties? • Answers follow. 10/7/2020 PPL LL(1) Parser Generators 5
Inductive class dictionaries • inductiveness already defined for class graphs – contains only good recursions: recursions that terminate Car = Motor = <belongs. To> Car. bad recursion, objects must be cyclic, cannot use for parsing: useless nonterminals 10/7/2020 PPL LL(1) Parser Generators 6
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 = <belongs. To> Car. Transmission =. Which nodes are inductive? 10/7/2020 PPL LL(1) Parser Generators 7
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! 10/7/2020 PPL LL(1) Parser Generators 8
Left-recursive class dictionaries • Bring us back to the same class without consuming input. • Java Compiler: left recursion detected: A : B | C. A -> C -> A B = “b”. C = A. 10/7/2020 PPL LL(1) Parser Generators 9
Ambiguous class dictionaries • cannot distinguish between objects. Print is not injective (one-to-one). Fruit : Apple | Orange. Apple = “a”. Orange = “a”. 10/7/2020 PPL LL(1) Parser Generators But: undecidable 10
Java Compiler: error message • Warning: Choice conflict … A common prefix is “a”. Consider using a lookahead of 2. . . 10/7/2020 PPL LL(1) Parser Generators 11
LL(1) class dictionaries • A special kind of nonambiguous class dictionaries. Membership can be checked efficiently. 10/7/2020 PPL LL(1) Parser Generators 12
Java Compiler LL(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. 10/7/2020 PPL LL(1) Parser Generators 13
Style rule • Ideally, make your class dictionaries LL(1), nonleft-recursive and inductive. 10/7/2020 PPL LL(1) Parser Generators 14














