{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

03-GramFormalParseTree

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

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

View Full Document Right Arrow Icon
Discussion #3 Chapter 10, Sections 1.3-5 1/20 Discussion #3 Grammar Formalization
Image of page 1

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

View Full Document Right Arrow Icon
Discussion #3 Chapter 10, Sections 1.3-5 2/20 Topics Grammar Definitions Parse Trees Constructing Parse Trees
Image of page 2
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
Image of page 3

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

View Full Document Right Arrow Icon
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
Image of page 4
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.
Image of page 5

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    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.

    Student Picture

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

  • Left Quote Icon

    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.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    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.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern