mirror of
https://github.com/RevCurtisP/C02.git
synced 2024-06-08 21:29:30 +00:00
Allowed declaration of functions with type int
This commit is contained in:
parent
b701f2477c
commit
200096f83f
15
src/dclrtn.c
15
src/dclrtn.c
|
@ -114,13 +114,14 @@ void pdecl(int m, int t) {
|
|||
/* Check for and Parse Type Keyword *
|
||||
* Args: m - Modifier Type */
|
||||
int ptype(int m) {
|
||||
int result = TRUE;
|
||||
if (wordis("STRUCT")) pstrct(m); //Parse 'const' declaration
|
||||
else if (wordis("ENUM")) penum(m); //Parse 'enum' declaration
|
||||
else if (wordis("CHAR")) pdecl(m, VTCHAR); //Parse 'char' declaration
|
||||
else if (wordis("VOID")) pdecl(m, VTVOID); //Parse 'void' declaration
|
||||
else result = FALSE;
|
||||
return result;
|
||||
int reslt = TRUE;
|
||||
if (wordis("STRUCT")) pstrct(m); //Parse 'const' declaration
|
||||
else if (wordis("ENUM")) penum(m); //Parse 'enum' declaration
|
||||
else if (wordis("CHAR")) pdecl(m, VTCHAR); //Parse 'char' declaration
|
||||
else if (wordis("INT")) pdecl(m, VTINT); //Parse 'int' declaration
|
||||
else if (wordis("VOID")) pdecl(m, VTVOID); //Parse 'void' declaration
|
||||
else reslt = FALSE;
|
||||
return reslt;
|
||||
}
|
||||
|
||||
int pmtype(int m) {
|
||||
|
|
|
@ -240,6 +240,7 @@ void setvar(int m, int t) {
|
|||
/* Parse and Compile Variable Declaration *
|
||||
* Uses: word - variable name */
|
||||
void addvar(int m, int t) {
|
||||
if (t == VTINT) ERROR("Integer Variables not yet Implemented", 0, EXIT_FAILURE)
|
||||
strcpy(vrname, word); //Save Variable Name
|
||||
if (fndvar(vrname)) ERROR("Duplicate declaration of variable '%s\n", vrname, EXIT_FAILURE)
|
||||
if (t == VTVOID) ERROR("Illegal Variable Type\n", 0, EXIT_FAILURE)
|
||||
|
|
|
@ -38,7 +38,7 @@ int mbrcnt; //Number of Struct Members Defined
|
|||
int mbridx; //Index into Struct Member Tables
|
||||
int mbrofs; //Member Offset
|
||||
|
||||
enum vtypes {VTVOID, VTCHAR, VTSTRUCT}; //Variable Types
|
||||
enum vtypes {VTVOID, VTCHAR, VTINT, VTSTRUCT}; //Variable Types
|
||||
|
||||
char datvar[DATASPC+1]; //Variable Data Storage
|
||||
int datlen[MAXVAR+1]; //Variable Data Length
|
||||
|
|
Loading…
Reference in New Issue
Block a user