int expression(struct Object *ast) {
int r = yylex();
+ struct Object *obj;
switch(r) {
case NUMBER:
- puts("number here bro");
- struct Object* obj = clone_object(number_object);
+ obj = clone_object(number_object);
list_append(ast, obj);
return message(ast);
break;
int message(struct Object *ast) {
int r = yylex();
+ struct Object *obj;
switch(r) {
case SYMBOL:
- printf("message : %s\n", yytext);
- struct Object* obj = clone_object(base_object);
+ obj = clone_object(base_object);
obj->type = T_MESSAGE;
obj->name = strdup(yytext);
list_append(ast, obj);
int length = mojo_list_length(ast->value.l_value);
- printf("ast->value.lv: %x, ast len: %d\n", ast->value.l_value, length);
+ printf("ast len: %d\n", length);
+ int i = 0;
+ for(i = 0; i < length; i++) {
+ struct Object *o = list_nth(ast, i);
+ printf("type: %d name: %s\n", o->type, o->name);
+ }
+}
+
+void execute(struct Object *ast) {
+
}
struct Object* list_append(struct Object *list, struct Object *o)
{
- if (list == NULL || list->type != T_LIST || list->type != T_BLOCK || list->value.l_value == NULL)
+ if (list == NULL || (list->type != T_LIST && list->type != T_BLOCK) || list->value.l_value == NULL) {
return nil_object;
+ }
- if (o == NULL)
+ if (o == NULL) {
return NULL;
-
+ }
mojo_list_append(list->value.l_value, o);
return o;
struct Object* list_remove(struct Object *list)
{
- if (list == NULL || list->type != T_LIST || list->type != T_BLOCK || list->value.l_value == NULL)
+ if (list == NULL || (list->type != T_LIST && list->type != T_BLOCK) || list->value.l_value == NULL)
return nil_object;
mojo_list_remove(list->value.l_value);
struct Object* list_nth(struct Object *list, int n)
{
- if (list == NULL || list->type != T_LIST || list->type != T_BLOCK || list->value.l_value == NULL)
+ if (list == NULL || (list->type != T_LIST && list->type != T_BLOCK) || list->value.l_value == NULL)
return nil_object;
struct Object *o = mojo_list_nth(list->value.l_value, n);
struct Object* list_last(struct Object *list)
{
- if (list == NULL || list->type != T_LIST || list->type != T_BLOCK || list->value.l_value == NULL)
+ if (list == NULL || (list->type != T_LIST && list->type != T_BLOCK) || list->value.l_value == NULL)
return nil_object;
struct Object *o = mojo_list_last(list->value.l_value);
struct Object* list_length(struct Object *list)
{
- if (list == NULL || list->type != T_LIST || list->type != T_BLOCK || list->value.l_value == NULL)
+ if (list == NULL || (list->type != T_LIST && list->type != T_BLOCK) || list->value.l_value == NULL)
return nil_object;
struct Object *o = clone_object(number_object);