Context-sensitive grammar transform: Compression and pattern matching