To show the problem, let's take undermentioned program
fun foo (p1, p2, p3) {
return p1
}
fun f1 (p1, p2, p3) local p4, p5 {
p4 := {};
while (1) do
case p2[p3[0]] of
A (a, b) ->
p5 := foo(p3, p2, a);
p4 := p5 : p4;
foo(p3, b, p5)
|B (a, b) ->
case P(foo(p3, p2, a), foo(p3, p2, b)) of
P (L (a), L (b)) -> p5 := L (a + b)
|P (a, b) -> p5 := foo(p3, a, b)
esac;
p4 := p5 : p4;
foo(p3, b, p5)
|C (a, b) ->
case P(foo(p3, p2, a), foo(p3, p2, b)) of
P (L (a), L (b)) -> p5 := L (a - b)
|P (a, b) -> p5 := foo(p3, a, b)
esac;
p4 := p5 : p4;
foo(p3, b, p5)
|D (a) ->
p5 := foo(p3, p2, a);
p4 := p5 : p4;
case p3[1][7] of
L (m) -> p3[1][7] := L (m + 1);
p3[2][m + 1] := p5
esac
|E ->
return p4
|a -> skip
esac
od;
return p4
}
write(7)
It's compilation time is about 1s. If we copy function f1 and rename it to f2, compilation time will be about 3s. Repeating this, we can get 33s for program with f3 and 50 MINUTES!!! for f4. Debugging shows that parser takes whole time
To show the problem, let's take undermentioned program
fun foo (p1, p2, p3) { return p1 } fun f1 (p1, p2, p3) local p4, p5 { p4 := {}; while (1) do case p2[p3[0]] of A (a, b) -> p5 := foo(p3, p2, a); p4 := p5 : p4; foo(p3, b, p5) |B (a, b) -> case P(foo(p3, p2, a), foo(p3, p2, b)) of P (L (a), L (b)) -> p5 := L (a + b) |P (a, b) -> p5 := foo(p3, a, b) esac; p4 := p5 : p4; foo(p3, b, p5) |C (a, b) -> case P(foo(p3, p2, a), foo(p3, p2, b)) of P (L (a), L (b)) -> p5 := L (a - b) |P (a, b) -> p5 := foo(p3, a, b) esac; p4 := p5 : p4; foo(p3, b, p5) |D (a) -> p5 := foo(p3, p2, a); p4 := p5 : p4; case p3[1][7] of L (m) -> p3[1][7] := L (m + 1); p3[2][m + 1] := p5 esac |E -> return p4 |a -> skip esac od; return p4 } write(7)It's compilation time is about 1s. If we copy function f1 and rename it to f2, compilation time will be about 3s. Repeating this, we can get 33s for program with f3 and 50 MINUTES!!! for f4. Debugging shows that parser takes whole time