vec_push_back(&(fnapp->value.fnapp.args), gc_addref(arg));
}
-
-//AST* Ann(char* name, AST* value)
-//{
-// (void)name;
-// (void)value;
-// return NULL;
-//}
-//
-//char* ann_name(AST* ann)
-//{
-// (void)ann;
-// return NULL;
-//}
-//
-//AST* ann_value(AST* ann)
-//{
-// (void)ann;
-// return NULL;
-//}
-//
-//AST* Block(void)
-//{
-// return NULL;
-//}
-//
-//void block_append(AST* expr)
-//{
-// (void)expr;
-//}
-//
-//size_t block_size(AST* block)
-//{
-// (void)block;
-// return 0;
-//}
-//
-//AST* block_get(size_t index)
-//{
-// (void)index;
-// return NULL;
-//}
-
void usage(void) {
fprintf(stderr, "%s\n",
"Usage: sclpl [options...] [-A artifact] [file...]\n"
- "\n-A<type> Emit the given type of artifact"
- "\n-h Print help information"
- "\n-v Enable verbose status messages");
+ "\n-A<artifact> Emit the given type of artifact"
+ "\n-h Print help information"
+ "\n-v Enable verbose status messages");
exit(1);
}
else
ret = expression(p);
}
- //printf("%p\n", ret);
- //else if (accept_str(p, T_ID, "type"))
- // return type_definition(p);
- //else if (accept_str(p, T_ID, "ann"))
- // return type_annotation(p);
return ret;
}
return app;
}
-
-#if 0
-static AST* type_annotation(Parser* p)
-{
- //shifttok(p, T_ID);
- //type(p);
- //expect(p, T_END);
- //reduce(Annotation);
- return NULL;
-}
-
-static AST* type_definition(Parser* p)
-{
- //expect(p, T_ID);
- //expect_str(p, T_ID, "is");
- //type(p);
- //expect(p, T_END);
- return NULL;
-}
-
-static AST* type(Parser* p) {
- //if (accept(p, T_LBRACE)) {
- // tuple(p);
- //} else {
- // expect(p, T_ID);
- // if (accept(p, T_LPAR)) {
- // function(p);
- // }
- //}
- return NULL;
-}
-
-static AST* tuple(Parser* p) {
- ////size_t mrk = mark(p);
- ////insert(p, T_ID, lexer_dup("tuple"));
- //do {
- // type(p);
- //} while (accept(p, T_COMMA));
- //expect(p, T_RBRACE);
- ////reduce(p, mrk);
- return NULL;
-}
-#endif
-
-
/* Parsing Routines
*****************************************************************************/
Parser* parser_new(char* prompt, FILE* input)
{
printf("%s:", tree_type_to_string(tree->type));
switch(tree->type) {
- case AST_STRING: printf("\"%s\"", string_value(tree)); break;
- case AST_SYMBOL: printf("%s", symbol_value(tree)); break;
- case AST_IDENT: printf("%s", ident_value(tree)); break;
- case AST_CHAR: printf("%c", char_value(tree)); break;
- case AST_INT: printf("%ld", integer_value(tree)); break;
- case AST_FLOAT: printf("%lf", float_value(tree)); break;
+ case AST_STRING: printf("\"%s\"", string_value(tree)); break;
+ case AST_SYMBOL: printf("%s", symbol_value(tree)); break;
+ case AST_IDENT: printf("%s", ident_value(tree)); break;
+ case AST_CHAR: printf("%c", char_value(tree)); break;
+ case AST_INT: printf("%ld", integer_value(tree)); break;
+ case AST_FLOAT: printf("%lf", float_value(tree)); break;
case AST_BOOL:
printf("%s", bool_value(tree) ? "true" : "false");
break;
void gc_delref(void* ptr);
void gc_swapref(void** dest, void* newref);
-// Redfine main
+// Redefine main
extern int user_main(int argc, char** argv);
/* Vector Implementation
vec_t* fnapp_args(AST* fnapp);
void fnapp_add_arg(AST* func, AST* arg);
-///* Annotation */
-//AST* Ann(char* name, AST* value);
-//char* ann_name(AST* def);
-//AST* ann_value(AST* def);
-
/* Lexer and Parser Types
*****************************************************************************/
typedef struct {