Download presentation

Presentation is loading. Please wait.

Published byAlaina Stevenson Modified over 3 years ago

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?

Similar presentations

OK

Writing a Function Rule Read the problem What are you looking for? Define the variables Pick the letters What do they stand for? Write the equation Solve.

Writing a Function Rule Read the problem What are you looking for? Define the variables Pick the letters What do they stand for? Write the equation Solve.

© 2019 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google