The
Chomsky
Hierarchy
Formal Grammars,
Languages, and the
Chomsky-Schtzenberger
Hierarchy
Overview
01 Personalities
02 Grammars and languages
03 The Chomsky hierarchy
04 Conclusion
Personalities
Noam Chomsky
Marcel Schtzenberger
Others.
01
Noam Chomsky
Bo
8.0 Regular Grammars and Regular Languages
Recall the general form of regular expressions:
If A is an alphabet, and a A , then a is a regular expression.
is a regular expression.
If r and s are regular expressions, then the following are also regular
exp
7.0 Non-Deterministic Finite Automata (NFA)
A non-deterministic finite automaton is one that (1) allows multiple arcs with
the same label to exit a node, and (2) allows arcs with a label. It is also
customary in an NFA to relax the completeness constraint
6.0 Recursive-Descent Parsing
Building a simple recognizer:
1. Convert BNF grammar to EBNF and syntax diagrams.
2. There must be an identifier token that points to the current token.
3. There must be a function match that:
a. tests whether current token i
5.0 EBNF (Extended BNF) and Syntax Diagrams
EBNF is the same as BNF, with three additional meta-symbols:
cfw_ which indicates 0 or more
[ ] which indicates optional
( | | ) which indicates sub-alternatives
EBNF has exactly the same expressive power as
3.0 Lexical Analysis
First, lets see a simplified overview of the compilation process:
Step 2: parsing
(syntax analysis)
source code file
(sequence of char)
Step 1: scanning
(lexical analysis)
Tokenized version
(sequence of tokens)
Parse Tree
Step 3:
code
2.0 Formal Grammars
Context-Free Grammar (CFG). A language generator consisting of:
1.
2.
3.
4.
a set T of terminals (usually denoted with lowercase letters)
a set N of non-terminals (usually denoted with uppercase letters)
a unique start symbol S 0 N
a s
1.0 Languages, Expressions, Automata
Alphabet: a finite set, typically a set of symbols.
Language: a particular subset of the strings that can be made from the alphabet.
ex:
an alphabet of digits = cfw_-,0,1,2,3,4,5,6,7,8,9
a language of integers = cfw_0,