Download presentation
Presentation is loading. Please wait.
1
UMBC CMSC 331 ONLINE LECTURE 3
SD Vick
2
Mini Lectures Left Recursion defined and explained with and caveats (see _Rem_1.swf) Left recursion removal example (see _rem_2.swf) (Full text of mini-lectures )
3
What’s the General Rule?
A -> A a1 | A a2 | … A am | b1 | b2 | bn ________________________________________ A-> b1 A’ | b2 A’ … bn A’ A’ -> a1 A’ | a2 A’ | … am A’ | e
4
Removing Left Recursion
Consider the following Grammar <z> -> <w> ? <x> | <z> ! <y> | a <z> <x> -> <z> * <x> | <x> / <y> | <w> <w> -> e | f Why is this Left Recursive? Now we must just pick our a’s and our b’s
5
The Mechanics <z> -> <w> ? <x> |
<z> ! <y> | a <z> <z> -> <w> ? <x> <z’> | a <z> <z’> <z’> -> ! <y> <z’> | e b1 a1 b2 Try the second rule on your own Here we have 2 b‘s and 1 a, what if the situation was reversed?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.