Title: Chapter 5 Context-Free Languages
1Chapter 5 Context-Free Languages
- Regular language are effective in describing
certain simple patterns. But it is not enough to
describe programming languages.
- Context-Free languages cover more complicated
languages.
Context free
2(No Transcript)
3It is not a linear grammar.
4Leftmost and Rightmost Derivations
Definition5.2 A derivation is said to be
leftmost if in each step the leftmost variable in
the sentential form is replaced. If in each step
the rightmost variable is replaced, we call the
derivation rightmost.
5Definition 5.3 Let G(V,T,S,P) be a context-free
grammar. An ordered tree is a derivation tree for
G if and only if it has the following properties
65.2 Parsing and Ambiguity
Parsing and Membership
7(No Transcript)
8Ambiguity in grammars and languages
S
9(No Transcript)
10.
5.3 Context-free Grammars and Programming
Languages
Why we learn the theory of formal
languages?----We use the theory to design
programming languages and to design the
interpreters and compiles for them.
A programming language has two aspects syntax
and semantics.
Related to context-free grammar.
11Chapter 7 Pushdown Automata
Pushdown Automata
12Definition 7.1 A nondeterministic pushdown
accepter or npda is defined by the septuple
13Context-free Language and Pushdown Automata
Theorem 7.1 For any context-free language L,
there is an npda M such that L L(M).
14(No Transcript)