diff options
-rw-r--r-- | ast.c | 8 | ||||
-rw-r--r-- | ast.h | 4 | ||||
-rw-r--r-- | com.c | 6 | ||||
-rw-r--r-- | g.peg | 4 |
4 files changed, 11 insertions, 11 deletions
@@ -48,9 +48,9 @@ AstNode astnode_new_list() { }; } -AstNode astnode_new_symbol(char *s) { +AstNode astnode_new_ident(char *s) { return (AstNode){ - .ty =AST_SYMBOL, + .ty =AST_IDENT, .as = { .str = s } @@ -79,7 +79,7 @@ void astnode_disp(AstNode *a) { } printf(")"); break; - case AST_SYMBOL: + case AST_IDENT: case AST_STRING: printf("%s:%s ",ast_ty_to_str(a->ty), a->as.str); break; @@ -88,7 +88,7 @@ void astnode_disp(AstNode *a) { } const char* ty_names[] = { - "list", "num", "symbol", "string" + "list", "num", "ident", "string" }; const char *ast_ty_to_str(AstTy ty) { return ty_names[ty]; @@ -7,7 +7,7 @@ typedef enum { AST_LIST, AST_NUM, - AST_SYMBOL, + AST_IDENT, AST_STRING, } AstTy; @@ -36,7 +36,7 @@ void astnode_append(AstNode *l, AstNode val); AstNode astnode_new_num(int n); AstNode astnode_new_list(); -AstNode astnode_new_symbol(char *s); +AstNode astnode_new_ident(char *s); AstNode astnode_new_string(char *s); void astnode_disp(AstNode *a); @@ -7,8 +7,8 @@ static void compile_node(Chunk *ch, AstNode a) { switch (a.ty) { - case AST_SYMBOL: - printf("can't compile symbol\n"); + case AST_IDENT: + printf("can't compile ident\n"); exit(1); break; case AST_STRING: @@ -23,7 +23,7 @@ static void compile_node(Chunk *ch, AstNode a) { AstVec l = a.as.list; #define CK(cond, msg) if (!(cond)) { puts(msg); exit(1); } CK(l.len == 3, "can only compile binary ops"); - CK(l.vals[0].ty == AST_SYMBOL, "can only call ops"); + CK(l.vals[0].ty == AST_IDENT, "can only call ops"); #undef CK char opchar = l.vals[0].as.str[0]; Op op; @@ -24,7 +24,7 @@ static const char *dbg_str[] = { "Evaluating rule", "Matched rule", "Abandoning expr <- l:list { $$ = l; } / n:number { $$ = n; } - / s:symbol { $$ = s; } + / i:ident { $$ = i; } / t:string { $$ = t; } list <- { $$ = astnode_new_list(); } @@ -34,7 +34,7 @@ list <- { $$ = astnode_new_list(); } ')' _ number <- < [0-9]+ > (! ident_char) _ { $$ = astnode_new_num(atoi($1)); } -symbol <- < ident_char+ > _ { $$ = astnode_new_symbol(strdup($1)); } +ident <- < ident_char+ > _ { $$ = astnode_new_ident(strdup($1)); } string <- '"' < [^"]+ > '"' { $$ = astnode_new_string(strdup($1)); } ident_char <- [-_a-zA-Z'+*0-9] |