Fixes to parsing and function pointers. It's a hack but it... works? kinda?
This commit is contained in:
parent
d848425701
commit
2bdbe6e6c0
|
@ -51,4 +51,4 @@ extern_ struct Token CurrentToken;
|
|||
extern_ char CurrentIdentifier[TEXTLEN + 1];
|
||||
|
||||
extern_ int CurrentGlobal;
|
||||
extern_ int CurrentLocal;
|
||||
extern_ int CurrentLocal;
|
||||
|
|
|
@ -374,12 +374,10 @@ struct SymbolTableEntry* AddSymbol(char* Name, int Type, int Structure, int Stor
|
|||
* * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
void Die(char* Error);
|
||||
|
||||
void DieMessage(char* Error, char* Reason);
|
||||
|
||||
void DieDecimal(char* Error, int Number);
|
||||
|
||||
void DieChar(char* Error, int Char);
|
||||
void DieBinary(char* Error, int Number);
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
|
|
12
src/Main.c
12
src/Main.c
|
@ -216,6 +216,18 @@ void DieDecimal(char* Error, int Number) {
|
|||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* A variant of Die that prints the int in binary.
|
||||
*/
|
||||
void DieBinary(char* Error, int Number) {
|
||||
char buf[33];
|
||||
itoa(Number, buf, 2);
|
||||
printf("%s: %s\n", Error, buf);
|
||||
fclose(OutputFile);
|
||||
unlink(OutputFileName);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/*
|
||||
* A variant of Die with an extra character attached.
|
||||
*/
|
||||
|
|
|
@ -208,6 +208,7 @@ struct ASTNode* ParseFunction(int Type) {
|
|||
if(NewFunction) {
|
||||
NewFunction->Elements = ParamCount;
|
||||
NewFunction->Start = Params;
|
||||
NewFunction->Type = RET_LONG;
|
||||
OldFunction = NewFunction;
|
||||
}
|
||||
|
||||
|
@ -507,7 +508,7 @@ struct ASTNode* PostfixStatement() {
|
|||
// (as functions have been called and arrays have been indexed)
|
||||
// Check that the variable is recognized..
|
||||
|
||||
if((Entry = FindSymbol(CurrentIdentifier)) == NULL || Entry->Structure != ST_VAR || Entry->Structure != ST_FUNC) {
|
||||
if((Entry = FindSymbol(CurrentIdentifier)) == NULL || (Entry->Structure != ST_VAR && Entry->Structure != ST_FUNC)) {
|
||||
DumpAllLists();
|
||||
DieMessage("Unknown Variable", CurrentIdentifier);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ static struct SymbolTableEntry* SearchList(char* Name, struct SymbolTableEntry*
|
|||
struct SymbolTableEntry* FindSymbol(char* Symbol) {
|
||||
struct SymbolTableEntry* Node;
|
||||
|
||||
if(CurrentFunction) {
|
||||
if(FunctionEntry) {
|
||||
Node = SearchList(Symbol, FunctionEntry->Start);
|
||||
if(Node)
|
||||
return Node;
|
||||
|
|
|
@ -48,7 +48,7 @@ int PrimitiveSize(int Type) {
|
|||
case RET_INT: return 4;
|
||||
case RET_LONG: return 8;
|
||||
default:
|
||||
DieDecimal("Bad type in PrimitiveSize", Type);
|
||||
DieBinary("Bad type in PrimitiveSize", Type);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -36,5 +36,5 @@ int :: main(int argc, char** argv) {
|
|||
glutDisplayFunc(display);
|
||||
glutMainLoop();
|
||||
|
||||
return 0;
|
||||
return (0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user