/* $Id$ */ %{ #include "y.tab.h" #include "kmakefile.h" #include #include #include char* yytmpbuf; int yywrap(void){ return 1; } int yyerror(const char* str){ extern char* yytext; fprintf(stderr, "Syntax error near `%s': `%s'\n", yytext, str); return 0; } %} %x STR %% \" { BEGIN(STR); yytmpbuf = malloc(1); yytmpbuf[0] = 0; } [^\\"]* { char* old = yytmpbuf; yytmpbuf = malloc(strlen(old) + strlen(yytext) + 1); strcpy(yytmpbuf, old); strcpy(yytmpbuf + strlen(old), yytext); free(old); } \\. { char* old = yytmpbuf; yytmpbuf = malloc(strlen(old) + 2); strcpy(yytmpbuf, old); strcpy(yytmpbuf + strlen(old), yytext + 1); free(old); } \" { BEGIN(0); yylval.scalar.type = KMAKE_STRING; yylval.scalar.value = yytmpbuf; return STRING; } ([ \t]*#[^\n]+) ; ([ \t]*\n[ \t]*) { return NEWLINE; } ([ \t]*\=[ \t]*) { return EQUAL; } ([^ "\n\(\),\t]+) { yylval.scalar.type = KMAKE_IDENT; yylval.scalar.value = malloc(strlen(yytext) + 1); strcpy(yylval.scalar.value, yytext); return IDENT; } ([ \t\n]*,[ \t\n]*) { return DELIM; } . { return yytext[0]; } %%