Languages, and the
02 Grammars and languages
03 The Chomsky hierarchy
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
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
source code file
(sequence of char)
Step 1: scanning
(sequence of tokens)
2.0 Formal Grammars
Context-Free Grammar (CFG). A language generator consisting of:
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
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.
an alphabet of digits = cfw_-,0,1,2,3,4,5,6,7,8,9
a language of integers = cfw_0,