some emission
This commit is contained in:
@ -29,4 +29,6 @@ Instruction *current;
|
||||
|
||||
int offset;
|
||||
int currentsp;
|
||||
CGNode *cgList;
|
||||
CGNode *cgList;
|
||||
|
||||
extern Stack* stack;
|
@ -18,7 +18,6 @@
|
||||
%{
|
||||
#include "../src/grammar.h"
|
||||
%}
|
||||
|
||||
%union {
|
||||
int integ;
|
||||
char* words;
|
||||
@ -166,6 +165,7 @@ definition:
|
||||
}
|
||||
|
||||
| ID {
|
||||
emit_function_start(table_lookup(cur,$1));
|
||||
//printf("ID: %s\n", $1);
|
||||
//printf("Type: %s\n", getType(table_lookup(getAncestor(cur), $1)));
|
||||
printdebug("see function def rule 1\n");
|
||||
@ -626,7 +626,9 @@ simple_statement:
|
||||
}
|
||||
|
||||
|
||||
| RETURN expression {$$ = getTypeEntry((TableNode*)$2);}
|
||||
| RETURN expression {
|
||||
$$ = getTypeEntry((TableNode*)$2);
|
||||
emit_return(tn_or_const(NODE,(TableNode*)$2));}
|
||||
|simple_statement error {yyerrok; printdebug("error in simple statement");}
|
||||
|
||||
|
||||
@ -852,7 +854,20 @@ expression:
|
||||
$$=$2;
|
||||
}
|
||||
|
||||
| memOp assignable
|
||||
| RESERVE assignable
|
||||
{
|
||||
int d = getAdInfoType((TableNode*)$2);
|
||||
if(d == TYPE_ARRAY ||d == TYPE_RECORD) {
|
||||
char* temp = temp_var_gen();
|
||||
TableNode* node = CreateEntry(cur,TYPE_PRIMITIVE, addr, temp, NULL);
|
||||
//NOTE ADD ASSIGNMENT EMIT HERE (MIGHT NEED TO PUSH TO STACK)
|
||||
$$ = node;
|
||||
} else {
|
||||
throw_error(ERROR_TYPE, "Invalid memOp expression with object %s of type %s.", getName((TableNode*)$2), getType((TableNode*)$2));
|
||||
$$=undefined;
|
||||
}
|
||||
}
|
||||
| RELEASE assignable
|
||||
{
|
||||
int d = getAdInfoType((TableNode*)$2);
|
||||
if(d == TYPE_ARRAY ||d == TYPE_RECORD) {
|
||||
@ -1064,22 +1079,6 @@ assignable:
|
||||
;
|
||||
|
||||
|
||||
|
||||
memOp:
|
||||
RESERVE
|
||||
{
|
||||
printdebug("reserve expression");
|
||||
}
|
||||
|
||||
| RELEASE
|
||||
{
|
||||
printdebug("release expression");
|
||||
}
|
||||
|
||||
|
||||
;
|
||||
|
||||
|
||||
constant:
|
||||
C_STRING
|
||||
{
|
||||
|
@ -102,6 +102,7 @@ void print_tok(int tok) {
|
||||
int run(FILE *alpha) {
|
||||
int token;
|
||||
top = cur = init(CreateScope(NULL, 1, 1));
|
||||
Stack *s = S_Init();
|
||||
|
||||
// If file is not found
|
||||
if (alpha == NULL) {
|
||||
|
Reference in New Issue
Block a user