Міністерство освіти і науки України
Національний університет „Львівська політехніка”
Кафедра прикладної математики
Розрахункова робота
з курсу „Системне програмування”:
Виконала: ст.гр. ПМ-32
Перевірив: Гладун В.Р.
Львів 2006
Початкова граматика:
Вибрана та перетворена граматика:
Будую відношення передування:
L(U)
R(U)
S
begin
.
O
O1, Z, M, P, U, z, if
O1, Z, M, P, U, V, I, I1, T, T1, K, z, c, )
O1
O1, Z, M, P, U, z, if
Z, M, P, U, V, I, I1, T, T1, K, z, c, )
Z
M, P, U, z, if
M, P, U, V, I, I1, T, T1, K, z, c, )
M
P, U, z, if
P, U, V, I, I1, T, T1, K, z, c, )
P
z
V, I, I1, T, T1, K, z, c, )
U
if
Z, M, P, U, V, I, I1, T, T1, K, z, c, )
Z1
Z, M, P, U, z, if
Z, M, P, U, V, I, I1, T, T1, K, z, c, )
V
I, I1, T, T1, K, z, c, (
I, I1, T, T1, K, z, c, )
I
I1, T, T1, K, z, c, (
I1, T, T1, K, z, c, )
I1
I1, T, T1, K, z, c, (
T, T1, K, z, c, )
T
T1, K, z, c, (
T1, K, z, c, )
T1
T1, K, z, c, (
K, z, c, )
K
z, c, (
z, c, )
S
O
O1
Z
M
P
U
Z1
V
I
I1
T
T1
K
begin
end
if
then
else
a
z
c
.
;
:=
>
<
+
-
*
(
)
S
O
=
O1
>
=
Z
>
>
>
M
>
>
>
P
>
>
>
U
>
>
>
Z1
=
V
>
=
>
>
=
I
>
>
>
>
=
=
>
I1
>
>
>
>
>
>
=
=
>
T
>
>
>
>
>
>
>
>
>
T1
>
>
>
=
>
>
>
>
>
=
>
K
>
>
>
>
>
>
>
>
>
>
>
begin
=
<
<
<
<
<
<
<
end
=
if
=
<
<
<
<
<
<
<
<
then
<
<
<
<
=
<
<
else
=
<
<
<
<
<
a
=
<
<
<
z
>
>
>
>
=
>
>
>
>
>
>
c
>
>
>
>
>
>
>
>
>
>
.
;
=
<
<
<
<
>
<
:=
=
<
<
<
<
<
>
<
<
<
<
=
<
<
<
<
<
<
<
>
=
<
<
<
<
>
<
<
<
+
=
<
<
<
<
<
-
=
<
<
<
<
<
*
=
<
<
<
(
=
<
<
<
<
<
<
<
<
)
>
>
>
>
>
>
>
>
>
>
Будую синтаксичний аналіз знизу догори:
$ < begin
$ < begin < i
$ < begin < z
$ < begin < z = :=
$ < begin < z = := < 1
$ < begin < z = := < c
$ < begin < z = := < c > ;
$ < begin < z = := < K > ;
$ < begin < z = := < T1 > ;
$ < begin < z = := < T > ;
$ < begin < z = := < I1 > ;
$ < begin < z = := < I > ;
$ < begin < z = := < V > ;
$ < begin < P > ;
$ < begin < M > ;
$ < begin < Z > ;
$ < begin < O1 = ;
$ < begin < O1 = ; < j
$ < begin < O1 = ; < z
$ < begin < O1 = ; < z = :=
$ < begin < O1 = ; < z = := < 10
$ < begin < O1 = ; < z = := < c
$ < begin < O1 = ; < z = := < c > ;
$ < begin < O1 = ; < z = := < K > ;
$ < begin < O1 = ; < z = := < T1 > ;
$ < begin < O1 = ; < z = := < T > ;
$ < begin < O1 = ; < z = := < I1 > ;
$ < begin < O1 = ; < z = := < I > ;
$ < begin < O1 = ; < z = := < V > ;
$ < begin < O1 = ; < P > ;
$ < begin < O1 = ; < M > ;
$ < begin < O1 = ; < Z > ;
$ < begin < O1 = ;
$ < begin < O1 = ; < k
$ < begin < O1 = ; < z
$ < begin < O1 = ; < z = :=
$ < begin < O1 = ; < z = := < 30
$ < begin < O1 = ; < z = := < c
$ < begin < O1 = ; < z = := < c > ;
$ < begin < O1 = ; < z = := < K > ;
$ < begin < O1 = ; < z = := < T1 > ;
$ < begin < O1 = ; < z = := < T > ;
$ < begin < O1 = ; < z = := < I1 > ;
$ < begin < O1 = ; < z = := < I > ;
$ < begin < O1 = ; < z = := < V > ;
$ < begin < O1 = ; < P > ;
$ < begin < O1 = ; < M > ;
$ < begin < O1 = ; < Z > ;
$ < begin < O1 = ;
$ < begin < O1 = ; < if
$ < begin < O1 = ; < if < (< j
$ < begin < O1 = ; < if < (< z
$ < begin < O1 = ; < if < (< z > <
$ < begin < O1 = ; < if < (< K > <
$ < begin < O1 = ; < if < (< T1 > <
$ < begin < O1 = ; < if < (< T > <
$ < begin < O1 = ; < if < (< I1 > <
$ < begin < O1 = ; < if < (< I = < < k
$ < begin < O1 = ; < if < (< I = < < z
$ < begin < O1 = ; < if < (< I1 = < < z > )
$ < begin < O1 = ; < if < (< I1 = < < K > )
$ < begin < O1 = ; < if < (< I1 = < < T1 > )
$ < begin < O1 = ; < if < (< I1 = < < T > )
$ < begin < O1 = ; < if < (< I1 = < < I1 > )
$ < begin < O1 = ; < if < (< I1 = < < I > )
$ < begin < O1 = ; < if < ( = V = )
$ < begin < O1 = ; < if < K
$ < begin < O1 = ; < if < K > a
$ < begin < O1 = ; < if < T1 = a
$ < begin < O1 = ; < if < T1 = a < (
$ < begin < O1 = ; < if < T1 = a < ( < j
$ < begin < O1 = ; < if < T1 = a < ( < z
$ < begin < O1 = ; < if < T1 = a < ( < z > >
$ < begin < O1 = ; < if < T1 = a < ( < K > >
$ < begin < O1 = ; < if < T1 = a < ( < T1 > >
$ < begin < O1 = ; < if < T1 = a < ( < T > >
$ < begin < O1 = ; < if < T1 = a < ( < I1 > >
$ < begin < O1 = ; < if < T1 = a < ( < I = > < i
$ < begin < O1 = ; < if < T1 = a < ( < I = > < z > )
$ < begin < O1 = ; < if < T1 = a < ( < I = > < K > )
$ < begin < O1 = ; < if < T1 = a < ( < I= > < T1 > )
$ < begin < O1 = ; < if < T1 = a < ( < I = > < T > )
$ < begin < O1 = ; < if < T1 = a < ( < I = > < I1 > )
$ < begin < O1 = ; < if < T1 = a < ( < I = > < I > )
$ < begin < O1 = ; < if < T1 = a < ( = V = )
$ < begin < O1 = ; < if < T1 = a = K
$ < begin < O1 = ; < if < T1
$ < begin < O1 = ; < if < T
$ < begin < O1 = ; < if < I1
$ < begin < O1 = ; < if < I
$ < begin < O1 = ; < if = V
$ < begin < O1 = ; < if = V = then < x
$ < begin < O1 = ; < if = V = then < z
$ < begin < O1 = ; < if = V = then < z = :=
$ < begin < O1 = ; < if = V = then < z = := < (
$ < begin < O1 = ; < if = V = then < z = := < ( < j
$ < begin < O1 = ; < if = V = then < z = := < ( < z > -
$ < begin < O1 = ; < if = V = then < z = := < ( < K > -
$ < begin < O1 = ; < if = V = then < z = := < ( < T1 > -
$ < begin < O1 = ; < if = V = then < z = := < ( < T > -
$ < begin < O1 = ; < if = V = then < z = := < ( < K > -
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 = - < i
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 = - < i > )
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 = - < z > )
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 = - < K > )
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 = - < T1 > )
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 = - < T > )
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 = - < i > )
$ < begin < O1 = ; < if = V = then < z = := < ( < I1 > )
$ < begin < O1 = ; < if = V = then < z = := < ( < I > )
$ < begin < O1 = ; < if = V = then < z = := < ( < V > )
$ < begin < O1 = ; < if = V = then < z = := < K
$ < begin < O1 = ; < if = V = then < z = := < T1
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < (
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < k > -
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < z > -
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < K > -
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < T1 > -
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < T > -
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < I1 = - < j
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < I1 = - < z > )
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < I1 = - < K > )
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < I1 = - < T1 > )
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < I1 = - < T > )
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < I1 > )
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < I > )
$ < begin < O1 = ; < if = V = then < z = := < T1 = * < ( < V > )
$ < begin < O1 = ; < if = V = then < z = := < T1 = * = K
$ < begin < O1 = ; < if = V = then < z = := < T1
$ < begin < O1 = ; < if = V = then < z = := < T
$ < begin < O1 = ; < if = V = then < z = := < I1
$ < begin < O1 = ; < if = V = then < z = := < I
$ < begin < O1 = ; < if = V = then < z = := = V
$ < begin < O1 = ; < if = V = then < P
$ < begin < O1 = ; < if = V = then < M
$ < begin < O1 = ; < if = V = then < Z
$ < begin < O1 = ; < if = V = then = Z1
$ < begin < O1 = ; < if = V = then = Z1 = else < x
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < i
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < z > +
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < K > +
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < T1> +
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < T > +
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < j
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < z
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < K > +
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < T1> +
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + = T > +
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < k
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < z
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < z > )
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < K > )
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + < T1> )
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( < I1 = + = T > )
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < ( = V = )
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < K
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < T1
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < T1 = * < 2
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < T1 = * < c
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < T1 = * = K
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < T1
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < T
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := < I1
$ < begin < O1 = ; < if = V = then = Z1 = else < z = := = V
$ < begin < O1 = ; < if = V = then = Z1 = else < P
$ < begin < O1 = ; < if = V = then = Z1 = else < P > ;
$ < begin < O1 = ; < if = V = then = Z1 = else < M > ;
$ < begin < O1 = ; < if = V = then = Z1 = else = Z > ;
$ < begin < O1 = ; < U > ;
$ < begin < O1 = ; < M > ;
$ < begin < O1 = ; = Z > ;
$ < begin < O1 = ;
$ < begin < O1 = ; < y
$ < begin < O1 = ; < z
$ < begin < O1 = ; < z = :=
$ < begin < O1 = ; < z = := < z
$ < begin < O1 = ; < z = := < z > +
$ < begin < O1 = ; < z = := < K > +
$ < begin < O1 = ; < z = := < T1 > +
$ < begin < O1 = ; < z = := < T > +
$ < begin < O1 = ; < z = := < I1 = + < 3
$ < begin < O1 = ; < z = := < I1 = + < c
$ < begin < O1 = ; < z = := < I1 = + < c > *
$ < begin < O1 = ; < z = := < I1 = + < T1 = * < i
$ < begin < O1 = ; < z = := < I1 = + < T1 = * < z > end
$ < begin < O1 = ; < z = := < I1 = + < T1 = * = K > end
$ < begin < O1 = ; < z = := < I1 = + < T1 > end
$ < begin < O1 = ; < z = := < I1 = + = T > end
$ < begin < O1 = ; < z = := < I1 > end
$ < begin < O1 = ; < z = := < I > end
$ < begin < O1 = ; < z = := = V > end
$ < begin < O1 = ; < P > end
$ < begin < O1 = ; < M > end
$ < begin < O1 = ; = Z > end
$ < begin < O1 > end
$ < begin = O = end = . > $
$ < S > $
Будую дерево виводу:
Будую тетради:
:= 1, _, i
;= 10, _, j
:= 30, _, k
– j, k, t1
BMZ, (13), t1
– j, i, t2
BMZ, (13), t2
– j, i, t3
– k, j, t4
* t3, t4, t5
:= t5, _, x
BR (17)
+ i, j, t6
+ t6, k, t7
*, t7, 2, t8
:= t8, _, x
+ x, 3, t9
* t9, i, t10
:= t10, _, y