lexer and parser optimizations

up to 30% higher compiling speed depending on template complexity