Ch2 CC
Ch2 CC
a = 1 ; if ( a + 1 ) b = 2 ;
re L(re ) Notes
a {a} Singleton set, for each a
in Σ
ε {ε} Empty string
{} Empty language
[abc]+
[abc]*
[0-9]+
[1-9][0-9]*
[a-zA-Z][a-zA-Z0-
9_]*
04/01/25 © 2002-08 Hal Perkins & UW CSE B-22
Abbreviations
Many systems allow abbreviations
to make writing and reading
definitions or specifications easier
name ::= re
c a t
r ε s
ε ε
ε s ε
ε ε
end of input
1 Accept EOF
(
2 Accept LPAREN
)
3 Accept RPAREN
;
4 Accept SCOLON
! =
5 6 Accept NEQ
< =
8 9 Accept LEQ
[0-9] [0-9]
11
[a-zA-Z] [a-zA-Z0-9_]
13
skipWhiteSpace();
switch(nextch) {
case '(': result = new Token(Token.LPAREN); getch(); return result;
case ‘)': result = new Token(Token.RPAREN); getch(); return result;
case ‘;': result = new Token(Token.SCOLON); getch(); return result;
// etc. …