mirror of
https://github.com/sigmasternchen/libparcival
synced 2025-03-15 03:48:55 +00:00
child handling done
This commit is contained in:
parent
5623bdce6b
commit
75800c531d
2 changed files with 18 additions and 4 deletions
18
src/main.c
18
src/main.c
|
@ -34,10 +34,12 @@ void generateHeader() {
|
|||
fprintf(output, "#include <templates.h>\n");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "extern void _registerTemplate(const char*, bool, void (*)(FILE*, va_list), void (*)(FILE*, va_list), size_t (*)(va_list));\n");
|
||||
fprintf(output, "extern void renderTemplateStart(const char*, FILE*, ...);\n")
|
||||
fprintf(output, "extern void renderTemplateEnd(const char*, FILE*, ...);\n")
|
||||
fprintf(output, "extern void renderTemplateStart(const char*, FILE*, ...);\n");
|
||||
fprintf(output, "extern void renderTemplateEnd(const char*, FILE*, ...);\n");
|
||||
fprintf(output, "\n");
|
||||
fprintf(output, "#define _renderTemplate(f, t, ...) renderTemplate(t, f, __VA_ARGS__)\n");
|
||||
fprintf(output, "#define _renderTemplateStart(f, t, ...) renderTemplateStart(t, f, __VA_ARGS__)\n");
|
||||
fprintf(output, "#define _renderTemplateEnd(f, t, ...) renderTemplateEnd(t, f, __VA_ARGS__)\n");
|
||||
fprintf(output, "\n");
|
||||
for (size_t i = 0; i < result.stats.no; i++) {
|
||||
fprintf(output, "%s\n", result.stats.texts[i]);
|
||||
|
@ -160,6 +162,10 @@ void generateSize() {
|
|||
fprintf(output, "\tsize_t %s = 0;\n", SIZE_ACCUMULATOR_VAR);
|
||||
generateArguments();
|
||||
|
||||
if (result.parent != NULL) {
|
||||
fprintf(output, "%s += sizeTemplate(%s);\n", SIZE_ACCUMULATOR_VAR, result.parent);
|
||||
}
|
||||
|
||||
parseTreeSize(1, result.tree);
|
||||
|
||||
fprintf(output, "\treturn %s;\n", SIZE_ACCUMULATOR_VAR);
|
||||
|
@ -230,8 +236,16 @@ void generateTree() {
|
|||
fprintf(output, "static void %s_%s_(FILE* out, va_list argptr) {\n", PRINT_PREFIX, name);
|
||||
generateArguments();
|
||||
|
||||
if (result.parent != NULL) {
|
||||
fprintf(output, "\t_renderTemplateStart(out, %s);\n", result.parent);
|
||||
}
|
||||
|
||||
parseTree(1, result.tree);
|
||||
|
||||
if (result.parent != NULL) {
|
||||
fprintf(output, "\t_renderTemplateEnd(out, %s);\n", result.parent);
|
||||
}
|
||||
|
||||
fprintf(output, "}\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -85,9 +85,9 @@ metaSection: /* empty */
|
|||
$$ = $4;
|
||||
addStat(&$$.stats, $2);
|
||||
}
|
||||
| STRUCTURE_BEGIN optionalWhitespaces structureType optionalWhitespaces OPEN_PARENTHESES text CLOSE_PARENTHESES optionalWhitespaces metaSection
|
||||
| STRUCTURE_BEGIN optionalWhitespaces structureType optionalWhitespaces OPEN_PARENTHESES text CLOSE_PARENTHESES optionalWhitespaces STRUCTURE_END metaSection
|
||||
{
|
||||
$$ = $9;
|
||||
$$ = $10;
|
||||
switch($3) {
|
||||
case RENDER_NODE:
|
||||
yyerror("render command not allowed in meta section; ignoring");
|
||||
|
|
Loading…
Reference in a new issue