一、
1. F 2. T
二、
1. A 2. A 3. B
三 1.
b
b b
b a
a
a
a
0 1 2 3
2.
(a) declaration type var-list
type int | float
var-list identifier ID ID , var-list | ε
(b)FIRST(declaration) = { int, float } FOLLOW(declaration) = { $ } FIRST(type) = { int, float} FOLLOW(type) = { identifier } FIRST(var-list) = { identifier } FOLLOW(var-list) = { $ } FIRST(ID) = { , , ε} FOLLOW(ID) = { $ }
(c)
int float , identifier $
declaration
declaration
type var-list
declaration type var-list type type int type float
var-list var-list
identifier ID
ID ID ,
var-list ID ε
(d)
Parsing Input Action
$declaration int x, y, z$ declaration type var-list
$var-list type int x, y, z$ type int
$var-list int int x, y, z$ match
$var-list x, y, z$ var-list identifier ID
$ID identifier x, y, z$ match
$ID , y, z$ ID , var-list
$var-list , , y, z$ match
$var-list y, z$ var-list identifier ID
$ID identifier y, z$ match
$ID , z$ ID , var-list
$var-list , , z$ match
$var-list z$ var-list identifier ID
$ID identifier z$ match
$ID $ ID ε
$ $ accept