Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMBC CMSC 331 O NLINE L ECTURE 3 P ART 1 SD Vick.

Similar presentations


Presentation on theme: "UMBC CMSC 331 O NLINE L ECTURE 3 P ART 1 SD Vick."— Presentation transcript:

1 UMBC CMSC 331 O NLINE L ECTURE 3 P ART 1 SD Vick

2 What is Left Recursion? Left Recursion is when you have a grammar with one or more rules of the following form A -> A  |  Example where  is and  is c  A -> A a b | c In the technique I’ll show you  can’t directly (or indirectly) start with A 1) A -> A a b | Ac is illegal 2) A -> A a b | Bc so is this B -> d | Ae A -> B -> A Why?

3 What’s the General Rule? A -> A    | A    | … A  m  |      n  A   A’ |   A’ …  n A’ A’ ->   A’ |   A’ | …  m A’ | 

4 -> ? | ! | a -> * | / | ->e | f Removing Left Recursion Consider the following Grammar Why is this Left Recursive? Now we must just  pick our  ’s  and  our  ’s

5 The Mechanics -> ? | ! | a    -> ? | a -> ! |  Try the second rule on your own Here we have 2  ‘s and 1 , what if the situation was reversed?


Download ppt "UMBC CMSC 331 O NLINE L ECTURE 3 P ART 1 SD Vick."

Similar presentations


Ads by Google