+/* ------------- package + class ids --------------- */
+
+PACKAGEANDCLASS : T_IDENTIFIER {
+
+ /* try current package */
+ $$ = registry_findclass(state->package, $1->text);
+
+ /* try explicit imports */
+ dictentry_t* e = dict_get_slot(state->imports, $1->text);
+ while(e) {
+ if($$)
+ break;
+ if(!strcmp(e->key, $1->text)) {
+ $$ = (class_signature_t*)e->data;
+ }
+ e = e->next;
+ }
+
+ /* try package.* imports */
+ import_list_t*l = state->wildcard_imports;
+ while(l) {
+ if($$)
+ break;
+ //printf("does package %s contain a class %s?\n", l->import->package, $1->text);
+ $$ = registry_findclass(l->import->package, $1->text);
+ l = l->next;
+ }
+
+ /* try global package */
+ if(!$$) {
+ $$ = registry_findclass("", $1->text);
+ }
+
+ if(!$$) syntaxerror("Could not find class %s\n", $1->text);
+}
+PACKAGEANDCLASS : PACKAGE '.' T_IDENTIFIER {
+ $$ = registry_findclass($1->text, $3->text);
+ if(!$$) syntaxerror("Couldn't find class %s.%s\n", $1->text, $3->text);
+}
+
+
+/* ----------function calls, constructor calls ------ */
+
+MAYBE_PARAM_VALUES : %prec prec_none {$$=0;}
+MAYBE_PARAM_VALUES : '(' MAYBE_EXPRESSION_LIST ')' {$$=$2}
+
+MAYBE_EXPRESSION_LIST : {$$=0;}
+MAYBE_EXPRESSION_LIST : EXPRESSION_LIST
+EXPRESSION_LIST : EXPRESSION {$$=list_new();
+ typedcode_t*t = malloc(sizeof(typedcode_t));
+ *t = $1;
+ list_append($$, t);}
+EXPRESSION_LIST : EXPRESSION_LIST ',' EXPRESSION {$$=$1;
+ typedcode_t*t = malloc(sizeof(typedcode_t));
+ *t = $3;
+ list_append($$, t);}
+
+NEW : "new" PACKAGEANDCLASS MAYBE_PARAM_VALUES {
+ MULTINAME(m, $2);
+ $$.c = code_new();
+ $$.c = abc_findpropstrict2($$.c, &m);
+ typedcode_list_t*l = $3;
+ int len = 0;
+ while(l) {
+ $$.c = code_append($$.c, l->typedcode->c); // push parameters on stack
+ l = l->next;
+ len ++;
+ }
+ $$.c = abc_constructprop2($$.c, &m, len);
+ $$.t = $2;
+}
+
+FUNCTIONCALL : T_IDENTIFIER '(' MAYBE_EXPRESSION_LIST ')' {
+ /* TODO: use abc_call (for calling local variables),
+ abc_callstatic (for calling own methods) */
+ $$.c = code_new();
+ $$.c = abc_findpropstrict($$.c, $1->text);
+ typedcode_list_t*l = $3;
+ int len = 0;
+ while(l) {
+ $$.c = code_append($$.c, l->typedcode->c); // push parameters on stack
+ l = l->next;
+ len ++;
+ }
+ $$.c = abc_callproperty($$.c, $1->text, len);
+ /* TODO: look up the functions's return value */
+ $$.t = TYPE_ANY;
+}
+
+RETURN: "return" %prec prec_none {
+ $$ = abc_returnvoid(0);
+}
+RETURN: "return" EXPRESSION {
+ $$ = $2.c;
+ $$ = abc_returnvalue($$);
+}
+