Lec8 - CMPSC 461: Programming Language Concepts Lecture 8...

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

View Full Document Right Arrow Icon
CMPSC 461: Programming Language Concepts Lecture 8 Instructor: Prof. Swarat Chaudhuri
Background image of page 1

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

View Full DocumentRight Arrow Icon
A context-free grammar A context-free grammar for {a m b n : m > n} S X Y X a X | є Y a Y b | є
Background image of page 2
A grammar for C-- Terminals: IF, WHILE, NUM, ID, REL Nonterminals: Comm Rules: AtomicStmt ::= IfStmt | WhileStmt | Assgn MS ::= AtomicStmt | MS AtomicStmt Assgn ::= ID ‘=‘ Exp ‘;’ Exp ::= NUM | ID | ‘(‘ Exp REL Exp ‘)’ IfStmt ::= IF ‘( Exp ‘) ‘{‘ MS ‘} WhileStmt ::= WHILE ‘( Exp ‘) ‘{‘ MS ‘}’
Background image of page 3

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

View Full DocumentRight Arrow Icon
But what about NUM, STRING, etc? We could of course define them using grammars. But we usually don’t as they are not abstract. That is, their encodings can vary. We assume that there is a lower-level specification for strings, numbers, etc. We will come back to this point of abstraction shortly.
Background image of page 4
When does an element belong to a set? When does a word belong to a formal language? When is a C command really a C command? Algorithmic question.
Background image of page 5

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

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

This note was uploaded on 09/30/2008 for the course CMPSC 461 taught by Professor Chaudhuri during the Fall '08 term at Penn State.

Page1 / 22

Lec8 - CMPSC 461: Programming Language Concepts Lecture 8...

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

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