ln003 - <else-part> ::= else <stmt> |...

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

View Full Document Right Arrow Icon
Grammars in Action Example: A simple programming language grammar. G: <Exp>* ::= <Exp> + <Exp> | <Exp> * <Exp> | ( <Exp> ) | a | b | c Terminal symbols!!! S = a S = a + b S = a + b * c S = (a + b) * c S = ((a + b)) S = c(a + b) S = (c)+(b) S = b++ S L ( G )?
Background image of page 1

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

View Full DocumentRight Arrow Icon
Grammars in Action c The empty symbol: <empty> c The only non-terminal that does not have a rule defining it. c That is the <empty> symbol derives nothing.
Background image of page 2
<empty> c Consider the grammar: G: <A>*::= a <B> | a <B> ::= b <B> | b G’: <A>*::= a <B> <B> ::= b <B> | <empty>
Background image of page 3

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

View Full DocumentRight Arrow Icon
Grammars in Action Consider the following grammar fragment: <if-stmt> ::= if <exp> then <stmt> <else-part>
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: <else-part> ::= else <stmt> | <empty> <exp> ::= . .. <stmt> ::= . .. <if-stmt> if <exp> then <stmt> <else-part> else <stmt> <if-stmt> if <exp> then <stmt> <else-part> <empty> Grammars in Action 2.1 a) Let L ( G ) be the language of all string consisting of zero or more a’s. 2.1 i) Let L ( G ) be the set of strings consisting of one or more a’s with a comma between each a and the next. 2.1 d) Let L ( G ) be the set of all strings consisting of one or more digits 0 – 9. HW#1 Chap 2 Exercises 1 b,c,g,j Due Wednesday 9/16...
View Full Document

This note was uploaded on 10/03/2011 for the course CSC 301 taught by Professor Hamel during the Spring '08 term at Rhode Island.

Page1 / 5

ln003 - <else-part> ::= else <stmt> |...

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

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