Implementing pattern matching in syntactic trees