p2: implement proto type-check, better yyerror

yyerror prints its file:line at the end.
types are existing classes or errors