summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ast.c8
-rw-r--r--ast.h4
-rw-r--r--com.c6
-rw-r--r--g.peg4
4 files changed, 11 insertions, 11 deletions
diff --git a/ast.c b/ast.c
index d0a7ffe..fda03d3 100644
--- a/ast.c
+++ b/ast.c
@@ -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];
diff --git a/ast.h b/ast.h
index b1569c4..0d5c190 100644
--- a/ast.h
+++ b/ast.h
@@ -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);
diff --git a/com.c b/com.c
index 2c73d67..7540a6d 100644
--- a/com.c
+++ b/com.c
@@ -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;
diff --git a/g.peg b/g.peg
index 172938f..552d76f 100644
--- a/g.peg
+++ b/g.peg
@@ -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]