summaryrefslogtreecommitdiffstats
path: root/dimension/main.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-12-19 19:16:33 -0500
committerTavian Barnes <tavianator@gmail.com>2009-12-19 19:27:26 -0500
commit970ecabc1ad30fa74e58f3d4ad9ccf41baffb8b0 (patch)
treefd2d4eb68391a5b911d5a158a5506487d04a6298 /dimension/main.c
parent51fda684667044e2fe3e56f28137ef5397ef03ee (diff)
downloaddimension-970ecabc1ad30fa74e58f3d4ad9ccf41baffb8b0.tar.xz
Implement a symbol table.
Diffstat (limited to 'dimension/main.c')
-rw-r--r--dimension/main.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/dimension/main.c b/dimension/main.c
index 2c2aea5..561ee99 100644
--- a/dimension/main.c
+++ b/dimension/main.c
@@ -155,28 +155,40 @@ main(int argc, char **argv) {
}
}
+ /* Construct the symbol table */
+ dmnsn_symbol_table *symtable = dmnsn_new_symbol_table();
+ dmnsn_push_symbol(symtable, "__file__", dmnsn_new_ast_string(input));
+
/* Debugging option - output the abstract syntax tree as an S-expression */
if (parse) {
- dmnsn_array *astree = dmnsn_parse(input_file, input);
+ dmnsn_astree *astree = dmnsn_parse(input_file, symtable);
if (!astree) {
fprintf(stderr, "Error parsing input file!\n");
+ dmnsn_delete_symbol_table(symtable);
+ fclose(input_file);
return EXIT_FAILURE;
}
dmnsn_print_astree_sexpr(stdout, astree);
dmnsn_delete_astree(astree);
+ dmnsn_delete_symbol_table(symtable);
fclose(input_file);
return EXIT_SUCCESS;
}
/* Realize the input */
printf("Parsing scene ...\n");
- dmnsn_scene *scene = dmnsn_realize(input_file, input);
+ dmnsn_scene *scene = dmnsn_realize(input_file, symtable);
if (!scene) {
fprintf(stderr, "Error realizing input file!\n");
+ dmnsn_delete_symbol_table(symtable);
+ fclose(input_file);
return EXIT_FAILURE;
}
+ dmnsn_delete_symbol_table(symtable);
+ fclose(input_file);
+
/* Allocate a canvas */
scene->canvas = dmnsn_new_canvas(width, height);
if (!scene->canvas) {