From d1c36566c70539ed0ea72875bdd8efab98a1fb4f Mon Sep 17 00:00:00 2001 From: Partho Bhattacharya Date: Fri, 7 Mar 2025 15:22:10 -0500 Subject: [PATCH] still working on resolving type name issue --- src/grammar.y | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/grammar.y b/src/grammar.y index 8ea0317..4c5e4e6 100644 --- a/src/grammar.y +++ b/src/grammar.y @@ -28,8 +28,6 @@ %type id_or_types %type types -%type expression -%type constant %token ID 101 %token T_INTEGER 201 %token T_ADDRESS 202 @@ -37,11 +35,11 @@ %token T_CHARACTER 204 %token T_STRING 205 %token C_INTEGER 301 -%token C_NULL 302 -%token C_CHARACTER 303 -%token C_STRING 304 -%token C_TRUE 305 -%token C_FALSE 306 +%token C_NULL 302 +%token C_CHARACTER 303 +%token C_STRING 304 +%token C_TRUE 305 +%token 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,$1,$3); } ; id_or_types: - ID - | types + ID {printf("string of id in id_or_type is %s\n",$1);} {$$ = $1;} + | types {printf("string of type in id_or_type is %s\n",$1);} {$$ = $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",$1);} {$$ = $1;} + | T_INTEGER {printf("string of T_INTEGER in types is %s\n",$1);} {$$ = $1;} + | T_ADDRESS {printf("string of T_ADDRESS in types is %s\n",$1);} {$$ = $1;} + | T_CHARACTER {printf("string of T_CHARACTER in types is %s\n",$1);} {$$ = $1;} + | T_BOOLEAN {printf("string of T_BOOLEAN in types is %s\n",$1);} {$$ = $1;} ; %%