03-GramFormalParseTree

03-GramFormalParseTree - Discussion #3 Chapter 10, Sections...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Discussion #3 Chapter 10, Sections 1.3-5 1/20 Discussion #3 Grammar Formalization 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 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. Discussion #3 Chapter 10, Sections 1.3-5 6/20 Examples of Grammars (again) Which are context-free grammars?...
View Full Document

This note was uploaded on 03/02/2012 for the course C S 236 taught by Professor Michaelgoodrich during the Winter '12 term at BYU.

Page1 / 20

03-GramFormalParseTree - Discussion #3 Chapter 10, Sections...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online