Termnonterm strings f n a or a if a in

Info iconThis preview shows page 1. Sign up to view the full content.

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

Unformatted text preview: spot –  Powerful enough to describe nGrossman Dan esQng, recursion Dan Grossmansome more general grammars –  But easy to parse, unlike Fall 2011 •  Not perfect Fall 2011 –  Cannot capture semanQcs, as in “variable must be declared” –  Can be ambiguous – i.e., mulQple ways to derive a string, which may lead to different “meanings” (e.g., order of operaQon) Winter 2013 UW CSE 401 (Michael Ringenburg) 32 Context- Free Grammars CSE341: Programming Languages CSE341: grammar G is Languages •  Formally, a Programming a tuple <N,Σ,P,S> where Lecture 1 L ymbols –  N a finite set of non- terminal secture 1 C ymbols C et of t Mechanics –  Σ a finite sourseerminal sourse Mechanics ML Variable Bindings ML Variable Bindings –  P a finite set of producQons •  A subset of N × (N ∪ Σ )*, i.e., a non- terminal right- Dan Grossman Dan Grossman hand side, and zero or more terminals and non- Fall 2011 Fall 2011 terminals on the leg- hand side. –  S the start symbol, a disQnguished element of N •  If not specified otherwise, this is usually assumed to be the non- terminal on the leg of the first producQon Winter 2013 UW CSE 401 (Michael Ringenburg) 33 Standard NotaQons CSE341: Programming CSE341: Programming Languages Languages •  •  •  •  •  •  a, b, c elements of Σ (terminals) 1 Lecture 1 Lecture Course Mechanics w, x, y, z Course Mechanics elements of Σ* (terminal strings) ML Variable Bindings ML Variable Bindings A, B, C elements of N (nonterminals) an Grossman Dan of N ( X, Y, Z elements GrossmanΣ Dterminals or nonterms) ∪ Fall 2011 Fall α, β, γ elements o2011 ∪ Σ )* (term/nonterm strings) f (N A α or A ::= α if <A, α> in P (producQons) Winter 2013 UW CSE 401 (Michael Ringenburg) 34 DerivaQon RelaQons (1) CSE341: Programming CSE341: Programming Languages Languages •  α A γ => α β γ iff A ::= β in P Lecture 1 Lecture 1 Course Course Mechanics Mechanics ML Variable ro...
View Full Document

This document was uploaded on 04/04/2014.

Ask a homework question - tutors are online