Compress data with context free grammars
GolfScript, 111 108 characters
1/{.}{:^1&lt;{^1$/,2&gt;.{;,)^&lt;.0?)!}*}do-1&lt;.,1&gt;{^1$/[10):10]*0+\+}{;^}if(\}while][0]%.,,]zip{))9+`&quot;=&quot;+\~&quot; &quot;*+}%n*

This is a quite clumsy approach using GolfScript. The second version performs much better than the initial one. It is much longer than the intended code but my implementation had nested do-loops and this caused issues with the interpreter.
Examples:
&gt; abcba
10=a b c b a

&gt; abcabcbc
10=11 11 12
11=a 12
12=b c

&gt; abcabcbcbcabcacacabcabab
10=11 12 12 13 14 14 c 11 15
11=15 13
12=c b
13=14 b
14=c a
15=a b