{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

03-GramFormalParseTree

# 03-GramFormalParseTree - Discussion#3 Grammar Formalization...

This preview shows pages 1–7. Sign up to view the full content.

Discussion #3 Chapter 10, Sections 1.3-5 1/20 Discussion #3 Grammar Formalization

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #3 Chapter 10, Sections 1.3-5 2/20 Topics Grammar Definitions Parse Trees Constructing Parse Trees
Discussion #3 Chapter 10, Sections 1.3-5 3/20 Formal Definition of a Grammar A grammar G is a 4-tuple: G = (V N , V T , S, Φ ), where – V N , V T , sets of non-terminal and terminal symbols – S V N , a start symbol Φ = a finite set of relations from (V T V N ) + to (V T V N ) * an element of Φ , ( α , β ), is written as α β and is called a production rule or a rewriting rule

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #3 Chapter 10, Sections 1.3-5 4/20 Examples of Grammars G 1 = (V N , V T , S, Φ ), where: V N = {S, B} V T = {a, b, c} S = S Φ = { S aBSc , S abc , Ba aB , Bb bb } G 2 = (V N , V T , S, Φ ), where: V N = {I, L, D} V T = {a, b, …, z, 0, 1, …, 9} S = I Φ = { I L | ID | IL , L a | b | … | z , D 0 | 1 | … | 9 } G 3 = (V N , V T , S, Φ ), where: Φ = { S aA , V N = {S, A, B } A aA | bB , V T = {a, b} B bB | ε } S = S
Discussion #3 Chapter 10, Sections 1.3-5 5/20 Definition of a Context-Free Grammar A context-free grammar is a grammar with the following restriction: The relation Φ is a finite set of relations from V N to (V T V N ) + i.e. the left hand side of a production is a single non- terminal i.e. the right hand side of any production cannot be empty Context-free grammars generate context-free languages. With slight variations, essentially all programming languages are context-free languages.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Discussion #3 Chapter 10, Sections 1.3-5 6/20 Examples of Grammars (again) Which are context-free grammars?
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern