diff options
author | Tavian Barnes <tavianator@gmail.com> | 2010-03-23 19:54:52 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2010-03-23 19:54:52 -0400 |
commit | 44a4fe4772dae123e2755e9b214d289715ec27c3 (patch) | |
tree | 7b2a5c0b4b7f287c524151ec8d71ebca0267ecec /dimension | |
parent | 5952fd7587af834d6fee3443ad97c2ee11be81e1 (diff) | |
download | dimension-44a4fe4772dae123e2755e9b214d289715ec27c3.tar.xz |
Use $var instead of __var__ for internal symbols.
Diffstat (limited to 'dimension')
-rw-r--r-- | dimension/directives.rules | 10 | ||||
-rw-r--r-- | dimension/grammar.epilogue | 8 | ||||
-rw-r--r-- | dimension/main.c | 2 | ||||
-rw-r--r-- | dimension/tokenize.c | 38 |
4 files changed, 29 insertions, 29 deletions
diff --git a/dimension/directives.rules b/dimension/directives.rules index c628807..82bdd8f 100644 --- a/dimension/directives.rules +++ b/dimension/directives.rules @@ -5,7 +5,7 @@ */ LANGUAGE_DIRECTIVE: "#include" STRING { - dmnsn_declare_symbol(symtable, "__include__", $2); + dmnsn_declare_symbol(symtable, "$include", $2); dmnsn_delete_astnode($2); } | "#declare" IDENTIFIER "=" RVALUE { @@ -31,18 +31,18 @@ LANGUAGE_DIRECTIVE: "#include" STRING { YYERROR; } - dmnsn_local_symbol(symtable, "__cond__", cond); + dmnsn_local_symbol(symtable, "$cond", cond); dmnsn_delete_astnode(cond); } | "#ifdef" "(" IDENTIFIER ")" { dmnsn_astnode *node = dmnsn_find_symbol(symtable, $3.ptr); - dmnsn_local_symbol(symtable, "__cond__", + dmnsn_local_symbol(symtable, "$cond", dmnsn_new_ast_integer(node ? 1 : 0)); dmnsn_delete_astnode($3); } | "#ifndef" "(" IDENTIFIER ")" { dmnsn_astnode *node = dmnsn_find_symbol(symtable, $3.ptr); - dmnsn_local_symbol(symtable, "__cond__", + dmnsn_local_symbol(symtable, "$cond", dmnsn_new_ast_integer(node ? 0 : 1)); dmnsn_delete_astnode($3); } @@ -72,7 +72,7 @@ LANGUAGE_DIRECTIVE: "#include" STRING { } | "#macro" IDENTIFIER "(" DECL_PARAMS ")" { dmnsn_declare_symbol(symtable, $2.ptr, $4); - dmnsn_local_symbol(symtable, "__macro__", + dmnsn_local_symbol(symtable, "$macro", dmnsn_new_ast_string($2.ptr)); dmnsn_delete_astnode($2); dmnsn_delete_astnode($4); diff --git a/dimension/grammar.epilogue b/dimension/grammar.epilogue index fddf088..9a5d8a6 100644 --- a/dimension/grammar.epilogue +++ b/dimension/grammar.epilogue @@ -23,12 +23,12 @@ dmnsn_astree * dmnsn_parse(FILE *file, dmnsn_symbol_table *symtable) { const char *filename; - dmnsn_astnode *fnode = dmnsn_find_symbol(symtable, "__file__"); + dmnsn_astnode *fnode = dmnsn_find_symbol(symtable, "$file"); if (fnode && fnode->type == DMNSN_AST_STRING) { filename = fnode->ptr; } else { filename = "<>"; - dmnsn_declare_symbol(symtable, "__file__", dmnsn_new_ast_string(filename)); + dmnsn_declare_symbol(symtable, "$file", dmnsn_new_ast_string(filename)); } void *scanner; @@ -52,12 +52,12 @@ dmnsn_astree * dmnsn_parse_string(const char *str, dmnsn_symbol_table *symtable) { const char *filename; - dmnsn_astnode *fnode = dmnsn_find_symbol(symtable, "__file__"); + dmnsn_astnode *fnode = dmnsn_find_symbol(symtable, "$file"); if (fnode && fnode->type == DMNSN_AST_STRING) { filename = fnode->ptr; } else { filename = "<string>"; - dmnsn_declare_symbol(symtable, "__file__", dmnsn_new_ast_string(filename)); + dmnsn_declare_symbol(symtable, "$file", dmnsn_new_ast_string(filename)); } void *scanner; diff --git a/dimension/main.c b/dimension/main.c index a03762f..9c7a5cf 100644 --- a/dimension/main.c +++ b/dimension/main.c @@ -179,7 +179,7 @@ main(int argc, char **argv) { /* Construct the symbol table */ dmnsn_symbol_table *symtable = dmnsn_new_symbol_table(); - dmnsn_declare_symbol(symtable, "__file__", dmnsn_new_ast_string(input)); + dmnsn_declare_symbol(symtable, "$file", dmnsn_new_ast_string(input)); dmnsn_declare_symbol(symtable, "version", dmnsn_new_ast_float(3.6)); /* Debugging option - output the abstract syntax tree as an S-expression */ diff --git a/dimension/tokenize.c b/dimension/tokenize.c index fb50cd6..6a811bf 100644 --- a/dimension/tokenize.c +++ b/dimension/tokenize.c @@ -217,9 +217,9 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, dmnsn_token_buffer *tbuffer = dmnsn_new_token_buffer(token, prev, filename); - dmnsn_astnode *inode = dmnsn_find_symbol(symtable, "__include__"); - dmnsn_assert(inode, "__include__ unset."); - dmnsn_assert(inode->type == DMNSN_AST_STRING, "__include__ has wrong type."); + dmnsn_astnode *inode = dmnsn_find_symbol(symtable, "$include"); + dmnsn_assert(inode, "$include unset."); + dmnsn_assert(inode->type == DMNSN_AST_STRING, "$include has wrong type."); const char *include = inode->ptr; char *filename_copy = strdup(filename); @@ -239,7 +239,7 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, dmnsn_diagnostic(llocp->first_filename, llocp->first_line, llocp->first_column, "Couldn't open include file '%s'", include); - dmnsn_undef_symbol(symtable, "__include__"); + dmnsn_undef_symbol(symtable, "$include"); free(local_include); dmnsn_delete_token_buffer(tbuffer); return NULL; @@ -252,7 +252,7 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, llocp->first_column, "Couldn't allocate buffer for include file '%s'", include); - dmnsn_undef_symbol(symtable, "__include__"); + dmnsn_undef_symbol(symtable, "$include"); fclose(file); free(local_include); dmnsn_delete_token_buffer(tbuffer); @@ -261,14 +261,14 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, dmnsn_yy_push_buffer(buffer, yyscanner); /* Stuff the filename in the symbol table to persist it */ - dmnsn_astnode *includes = dmnsn_find_symbol(symtable, "__includes__"); + dmnsn_astnode *includes = dmnsn_find_symbol(symtable, "$includes"); if (!includes) { - dmnsn_declare_symbol(symtable, "__includes__", dmnsn_new_ast_array()); - includes = dmnsn_find_symbol(symtable, "__includes__"); + dmnsn_declare_symbol(symtable, "$includes", dmnsn_new_ast_array()); + includes = dmnsn_find_symbol(symtable, "$includes"); } - dmnsn_assert(includes, "__includes__ unset."); + dmnsn_assert(includes, "$includes unset."); dmnsn_assert(includes->type == DMNSN_AST_ARRAY, - "__includes__ has wrong type."); + "$includes has wrong type."); dmnsn_astnode fnode = dmnsn_new_ast_string(local_include); free(local_include); @@ -277,7 +277,7 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, dmnsn_push_scope(symtable); - dmnsn_undef_symbol(symtable, "__include__"); + dmnsn_undef_symbol(symtable, "$include"); return tbuffer; } @@ -427,8 +427,8 @@ dmnsn_if_buffer(int token, dmnsn_token_buffer *prev, dmnsn_token_buffer *tbuffer = dmnsn_new_token_buffer(token, prev, filename); - dmnsn_astnode *cnode = dmnsn_find_symbol(symtable, "__cond__"); - dmnsn_assert(cnode, "__cond__ unset."); + dmnsn_astnode *cnode = dmnsn_find_symbol(symtable, "$cond"); + dmnsn_assert(cnode, "$cond unset."); bool cond = false; if (cnode->type == DMNSN_AST_INTEGER) { @@ -436,10 +436,10 @@ dmnsn_if_buffer(int token, dmnsn_token_buffer *prev, } else if (cnode->type == DMNSN_AST_FLOAT) { cond = (*(double *)cnode->ptr) ? true : false; } else { - dmnsn_assert(false, "__cond__ has wrong type."); + dmnsn_assert(false, "$cond has wrong type."); } - dmnsn_undef_symbol(symtable, "__cond__"); + dmnsn_undef_symbol(symtable, "$cond"); int nesting = 1, else_seen = 0; while (1) { @@ -680,13 +680,13 @@ dmnsn_declare_macro(int token, dmnsn_token_buffer *prev, dmnsn_token_buffer *tbuffer = dmnsn_new_token_buffer(token, NULL, filename); - dmnsn_astnode *mname = dmnsn_find_symbol(symtable, "__macro__"); - dmnsn_assert(mname, "__macro__ unset."); - dmnsn_assert(mname->type == DMNSN_AST_STRING, "__macro__ has wrong type."); + dmnsn_astnode *mname = dmnsn_find_symbol(symtable, "$macro"); + dmnsn_assert(mname, "$macro unset."); + dmnsn_assert(mname->type == DMNSN_AST_STRING, "$macro has wrong type."); dmnsn_astnode *mnode = dmnsn_find_symbol(symtable, mname->ptr); dmnsn_assert(mnode, "#macro unset."); dmnsn_assert(mnode->type == DMNSN_AST_MACRO, "#macro has wrong type."); - dmnsn_undef_symbol(symtable, "__macro__"); + dmnsn_undef_symbol(symtable, "$macro"); int nesting = 1; while (1) { |