1 /* $NetBSD: pure_error.y,v 1.1.1.4 2013/04/06 14:45:27 christos Exp $ */ 2 3 %{ 4 5 #ifdef YYBISON 6 #define YYSTYPE int 7 #define YYLEX_PARAM &yylval 8 #define YYLEX_DECL() yylex(YYSTYPE *yylval) 9 #define YYERROR_DECL() yyerror(const char *s) 10 int YYLEX_DECL(); 11 static void YYERROR_DECL(); 12 #endif 13 14 %} 15 16 %% 17 S: error 18 %% 19 20 #include <stdio.h> 21 22 #ifdef YYBYACC 23 extern int YYLEX_DECL(); 24 #endif 25 26 int main(void)27main(void) 28 { 29 printf("yyparse() = %d\n", yyparse()); 30 return 0; 31 } 32 33 int yylex(YYSTYPE * value)34yylex(YYSTYPE *value) 35 { 36 return value ? 0 : -1; 37 } 38 39 static void yyerror(const char * s)40yyerror(const char* s) 41 { 42 printf("%s\n", s); 43 } 44