optimize ast for typed parser