0 Up votes0 Down votes

3 views9 pagesMELJUN CORTES Automata Lecture Ambiguity 2

Jun 12, 2015

© © All Rights Reserved

PDF, TXT or read online from Scribd

MELJUN CORTES Automata Lecture Ambiguity 2

© All Rights Reserved

3 views

MELJUN CORTES Automata Lecture Ambiguity 2

© All Rights Reserved

You are on page 1of 9

AMBIGUITY

Ambiguity in Context-Free Grammars

Introduction

Consider

the

following

grammar G = (V, , R, S)

where

V = {<expr>}

= {+, , a, b, c, (, )}

S = {<expr>}

and the set of rules R is

1. <expr><expr>+<expr>

<expr><expr>

(<expr>)abc

Ambiguity

* Property of STI

Page 1 of 9

string a+b+c is as follows:

<expr> <expr> + <expr>

a + <expr>

a + <expr> + <expr>

a + b + <expr>

a+b+c

The parse

derivation is

tree

for

the

<expr>

<expr>

<expr>

<expr>

Ambiguity

<expr>

* Property of STI

Page 2 of 9

leftmost derivation for the

string a + b + c which is as

follows:

<expr> <expr> + <expr>

<expr> + <expr> +

<expr>

a + <expr> + <expr>

a + b + <expr>

a+b+c

The parse

derivation is

tree

for

the

<expr>

<expr>

<expr>

a

Ambiguity

<expr>

<expr>

b

* Property of STI

Page 3 of 9

Ambiguity

added b + c first. And then it

added a to this sum.

added a + b first. And then it

added this sum to c.

a grammar in more than one

way, then the grammar is said

to be ambiguous and the

string is derived ambiguously.

when a string has two or more

different leftmost derivations

(or rightmost derivations) or

two or more parse trees, then

the grammar is ambiguous.

* Property of STI

Page 4 of 9

leftmost derivation for the

string a + b c is as follows:

<expr> <expr> + <expr>

a + <expr>

a + <expr> <expr>

a + b <expr>

a+bc

The parse

derivation is

tree

for

the

<expr>

<expr>

<expr>

<expr>

Ambiguity

<expr>

* Property of STI

Page 5 of 9

leftmost derivation for the

string a+bc which is as

follows:

<expr> <expr> <expr>

<expr> + <expr>

<expr>

a + <expr> <expr>

a + b <expr>

a+bc

The parse

derivation is

tree

for

the

<expr>

<expr>

<expr>

Ambiguity

<expr>

<expr>

* Property of STI

Page 6 of 9

Ambiguity

multiplied b c first. And then

it added a to the product.

added a + b first. And then it

multiplied the sum to c.

operation

has

a

higher

precedence over the addition

operation, the first derivation

will produce the correct result.

produce erroneous results, the

grammar must be rewritten to

remove any ambiguities.

* Property of STI

Page 7 of 9

Rewriting grammar G to

remove ambiguity results in

1. <expr> <term>

<expr>+<term>

2. <term> <factor>

<term><factor>

3. <factor> (<expr>)abc

The parse tree for a + b c is

<expr>

<expr>

Ambiguity

<term>

<term>

<term>

<factor>

<factor>

<factor>

* Property of STI

Page 8 of 9

A string w is derived

ambiguously in context-free

grammar G if it has two or

more

distinct

leftmost

derivations, two or more

distinct rightmost derivations,

or two or more distinct parse

trees.

Grammar G is ambiguous if it

generates

some

string

ambiguously.

Ambiguity

* Property of STI

Page 9 of 9

- Learning2search PythonUploaded byxbsd
- Log-LogUploaded byGre Urb
- class12-13Uploaded byTaqi Shah
- CFGUploaded byAwais_Khan_5673
- QTP SimpleUploaded byaavijitdas
- BridgeUploaded byKanchana V Subbaiah
- exercise04.pdfUploaded bycompiler&automata
- Ch03Uploaded byranga231980
- 2015 Hulu Click SystemUploaded byamsamu@gmail.com
- Bastion HostUploaded byIan E Comings
- A.univ.PaperUploaded bySan
- New Microsoft PowerPoint Presentation (2)Uploaded bySamar Hamady
- Awr RecreateUploaded byRaj Kumar
- Solution of TP as LP.xlsxUploaded byRayana Bhargav Sai
- hw10solnsUploaded bybombzhome
- MCS-031 Solved 2014-15Uploaded bymuralidhar
- ardlboundUploaded byRoby Arrahman
- Selenium LocatorsUploaded byPrakhar Sharma
- bdf1Uploaded byMohanKumar
- Investment Cost ModelUploaded byfrosticemaiden
- Quiz3Aug2017Uploaded byFariz Lukman
- Solutie_Lucrarea_7.pdfUploaded byCosti Cochet
- Shape Newcourse STUploaded byHgfghf Ghfghgf
- Deductive LogcUploaded byAndrea Loredana Simion
- Survey Table StructuresUploaded bySean Dorman
- 2008-05 ExceptionsUploaded byOleksiy Kovyrin
- Payn Pctn Move to Production ListUploaded bypsaikrish
- 514-2005-perfect square trinomials--explanation practiceUploaded byapi-258903855
- Ch07_19Uploaded byPrincess Contawe Corpuz
- Binomial TheoremsUploaded bymanmonbha

- TCU 2019 Certificate Recognization SERVICE AWARD 5 YearsUploaded byMELJUN CORTES, MBA,MPA
- TCU 2018 Certificate of Recognition Outstanding FacultyUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2018 2019Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2018 2019Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2017 2018Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2017 2018Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2016 2017Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2016 2017Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2015 2016Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2015 2016Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 2nd Semester 2014 2015Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU Evaluation Faculty TCU Taguig City 1st Semester 2014 2015Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU 2019 Certificate Recognization SERVICE AWARD 5 years of TCU OSASUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU 2018 Certificate of Recognition Outstanding Faculty of TCUUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC III BookkeepingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC II CSS Computer Systems ServicingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA TM 1 2016 Trainer's Methodology IUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA Data Encoder Eligibility 2Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA Data Encoder Eligibility 1Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC II PC OperationsUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC I Data EncoderUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA License NC I TechnicianUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA 2009 Tm Am Trainers AMUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TESDA 2009 CHS NC II 392 Hours Certificate of Training Computer Hardware ServicingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU OSAS 2019 Certificate Recognization SERVICE AWARD 5 YearsUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES TCU 2018 Certificate of Recognition Outstanding Faculty - TEACHERUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM COGNOS Certified 2013Uploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM Training Certificate DATA WareHousingUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM Training Certificate BIG DATAUploaded byMELJUN CORTES, MBA,MPA
- MELJUN CORTES IBM Training Certificate Predictive AnalyticsUploaded byMELJUN CORTES, MBA,MPA

- 1.Describing Syntax and Semantics.pptxUploaded bynsavi16edu
- TautologyUploaded byMontri Budpun
- Ruby BnfUploaded byChristian Ferraz
- Lec 3_predicates&quantifiers1.pptxUploaded byJulie Pardo Trinidad
- Automata Theory TutorialUploaded byRittika Guha
- Hacking ErlangUploaded byapi-26318246
- CS402FINALTERM_SOLVEDPAPER2Uploaded byAbdul Sattar Kiani
- CHAPTER-7.pptxUploaded byRollyn Dee De Marco Piocos
- Introduction to Automata Theory Text Book AnsUploaded bySuganya Selvaraj
- gppgUploaded byf1125706
- SLLPUploaded byAnuj Sharma
- UPENN Phil 015 Handout 1Uploaded bymatthewkimura
- Chapter 10. Manipulating Context-free GrammarsUploaded bykims3515354178
- Logic HandoutUploaded byakmaken
- CHAPTER 1Uploaded byIrfan Fazail
- Left Associative GrammersUploaded byGaganjot Singh
- PPT Teori Himpunan Dan LogikaUploaded byKou Junior
- Compiler Assignment 2, 3 ,4 5(1)Uploaded byKrisʜŋʌ Cʜoʋɗhʌrƴ
- Logic & ProofsUploaded byShashank Sabhlok
- Logical-Operators.pptxUploaded bySophia Nicole Demonise
- Compiler Design - Lecture Notes, Study Material and Important Questions, AnswersUploaded byM.V. TV
- Lexical AnalysisUploaded byLoving Heart
- Boolean ExpressionsUploaded bysunderthomas
- jhtp5_11Uploaded byprofessorrdsharma
- Makalah-IF2211-2013-048Uploaded byAkbar Syam
- David Bostock - Intermediate Logic.pdfUploaded byAnonymous 0kYj4n2F
- 15A05601 Compiler DesignUploaded byRasamsetty Anu
- Syntax AnalysisUploaded byHillary Auxi Bantu
- Compiler Lab VivaUploaded byGaurav Sharma
- 15CS54 DEC18-JAN19Uploaded byMallesh

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.