%}
+%s verbatim
+
%%
"(" { return LPAREN; }
")" { return RPAREN; }
-"{{" { return LBRACKET; }
-"}}" { return RBRACKET; }
+"{{" { BEGIN(verbatim); return LBRACKET; }
+"}}" { BEGIN(INITIAL); return RBRACKET; }
"," { return COMMA; }
"foreach" { return FOREACH; }
-[a-zA-Z0-9]+ { return WORD; }
"$$" { return DOLDOL; }
-[ \t\n]+ /* { return SPACES; } */
+
+[a-zA-Z0-9]+ { return WORD; }
+<verbatim>[ \t\n]+ { return SPACES; }
+[ \t\n]+ /* otherwise eat up spaces */ { }
parse_block(b);
char **p = b->parameters;
- char *c = b->contents;
- if (c == NULL)
+
+ if (b->contents == NULL)
fail("the impossible happened : b->contents == NULL !, file: %s, line %d", __FILE__, __LINE__);
- while(strcmp(*p, "\0") != 0) {
- while(c != '\0') {
- if (*c == '$' && *c+1 == '$') {
- printf("%s", p);
- c++; /* skip them second '$' */
+ while(*p != NULL) {
+ char *c = b->contents;
+ int i = 0;
+
+ for(i = 0; i < b->contents_length && c != NULL; i++) {
+ if (*c == '$' && *(c+1) == '$') {
+ printf("%s", *p);
+ c++; /* skip the second '$' */
} else {
printf("%c", *c);
}
-
+
c++;
}
+
p++;
}
}
fail("the impossible happened : b == NULL !, file: %s, line %d", __FILE__, __LINE__);
b->contents = malloc(8192);
+ b->contents_length = 0;
if (b->contents == NULL)
fail("Unable to alloc memory for input buffer", __FILE__, __LINE__);
t = yylex();
}
+ b->contents_length = i;
+
return;
}