some emission
This commit is contained in:
@ -30,3 +30,5 @@ Instruction *current;
|
|||||||
int offset;
|
int offset;
|
||||||
int currentsp;
|
int currentsp;
|
||||||
CGNode *cgList;
|
CGNode *cgList;
|
||||||
|
|
||||||
|
extern Stack* stack;
|
@ -18,7 +18,6 @@
|
|||||||
%{
|
%{
|
||||||
#include "../src/grammar.h"
|
#include "../src/grammar.h"
|
||||||
%}
|
%}
|
||||||
|
|
||||||
%union {
|
%union {
|
||||||
int integ;
|
int integ;
|
||||||
char* words;
|
char* words;
|
||||||
@ -166,6 +165,7 @@ definition:
|
|||||||
}
|
}
|
||||||
|
|
||||||
| ID {
|
| ID {
|
||||||
|
emit_function_start(table_lookup(cur,$1));
|
||||||
//printf("ID: %s\n", $1);
|
//printf("ID: %s\n", $1);
|
||||||
//printf("Type: %s\n", getType(table_lookup(getAncestor(cur), $1)));
|
//printf("Type: %s\n", getType(table_lookup(getAncestor(cur), $1)));
|
||||||
printdebug("see function def rule 1\n");
|
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");}
|
|simple_statement error {yyerrok; printdebug("error in simple statement");}
|
||||||
|
|
||||||
|
|
||||||
@ -852,7 +854,20 @@ expression:
|
|||||||
$$=$2;
|
$$=$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);
|
int d = getAdInfoType((TableNode*)$2);
|
||||||
if(d == TYPE_ARRAY ||d == TYPE_RECORD) {
|
if(d == TYPE_ARRAY ||d == TYPE_RECORD) {
|
||||||
@ -1064,22 +1079,6 @@ assignable:
|
|||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
memOp:
|
|
||||||
RESERVE
|
|
||||||
{
|
|
||||||
printdebug("reserve expression");
|
|
||||||
}
|
|
||||||
|
|
||||||
| RELEASE
|
|
||||||
{
|
|
||||||
printdebug("release expression");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
constant:
|
constant:
|
||||||
C_STRING
|
C_STRING
|
||||||
{
|
{
|
||||||
|
@ -102,6 +102,7 @@ void print_tok(int tok) {
|
|||||||
int run(FILE *alpha) {
|
int run(FILE *alpha) {
|
||||||
int token;
|
int token;
|
||||||
top = cur = init(CreateScope(NULL, 1, 1));
|
top = cur = init(CreateScope(NULL, 1, 1));
|
||||||
|
Stack *s = S_Init();
|
||||||
|
|
||||||
// If file is not found
|
// If file is not found
|
||||||
if (alpha == NULL) {
|
if (alpha == NULL) {
|
||||||
|
Reference in New Issue
Block a user