still working on resolving type name issue

This commit is contained in:
Partho Bhattacharya
2025-03-07 15:22:10 -05:00
parent f33b4566ea
commit d1c36566c7

View File

@ -28,8 +28,6 @@
%type <words> id_or_types
%type <words> types
%type expression
%type constant
%token <words> ID 101
%token <words> T_INTEGER 201
%token <words> T_ADDRESS 202
@ -37,11 +35,11 @@
%token <words> T_CHARACTER 204
%token <words> T_STRING 205
%token <integ> C_INTEGER 301
%token C_NULL 302
%token C_CHARACTER 303
%token C_STRING 304
%token C_TRUE 305
%token C_FALSE 306
%token <words> C_NULL 302
%token <words> C_CHARACTER 303
%token <words> C_STRING 304
%token <words> C_TRUE 305
%token <words> C_FALSE 306
%token WHILE 401
%token IF 402
%token THEN 403
@ -109,17 +107,17 @@ prototype:
L_PAREN EXTERNAL R_PAREN FUNCTION ID COLON ID;
definition:
TYPE ID COLON dblock
TYPE ID COLON dblock
| TYPE ID COLON constant ARROW ID
| function_declaration
//| function_declaration
| TYPE ID COLON id_or_types ARROW id_or_types
| ID parameter ASSIGN sblock
;
function_declaration:
FUNCTION ID COLON ID
| EXTERNAL FUNCTION ID COLON ID
;
//function_declaration:
// FUNCTION ID COLON ID
//| EXTERNAL FUNCTION ID COLON ID
//;
parameter:
L_PAREN ID R_PAREN
@ -145,12 +143,12 @@ declaration_list:
;
declaration:
id_or_types COLON ID {CreateEntry(cur,$1,$3); }
id_or_types COLON ID {CreateEntry(cur,$<words>1,$<words>3); }
;
id_or_types:
ID
| types
ID {printf("string of id in id_or_type is %s\n",$<words>1);} {$$ = $<words>1;}
| types {printf("string of type in id_or_type is %s\n",$<words>1);} {$$ = $<words>1;}
;
statement_list:
@ -226,11 +224,11 @@ constant:
;
types:
T_STRING
| T_INTEGER
| T_ADDRESS
| T_CHARACTER
| T_BOOLEAN
T_STRING {printf("string of T_STRING in types is %s\n",$<words>1);} {$$ = $<words>1;}
| T_INTEGER {printf("string of T_INTEGER in types is %s\n",$<words>1);} {$$ = $<words>1;}
| T_ADDRESS {printf("string of T_ADDRESS in types is %s\n",$<words>1);} {$$ = $<words>1;}
| T_CHARACTER {printf("string of T_CHARACTER in types is %s\n",$<words>1);} {$$ = $<words>1;}
| T_BOOLEAN {printf("string of T_BOOLEAN in types is %s\n",$<words>1);} {$$ = $<words>1;}
;
%%