From c2b5042e9a0eea9e8fda8fd12f734846367f3bc0 Mon Sep 17 00:00:00 2001 From: Simon Staal Date: Mon, 4 Mar 2024 23:44:01 +0100 Subject: [PATCH] Renamed parser types --- src/lexer.flex | 14 +++++++------- src/parser.y | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lexer.flex b/src/lexer.flex index 2d7ee2f..120fe38 100644 --- a/src/lexer.flex +++ b/src/lexer.flex @@ -54,14 +54,14 @@ IS (u|U|l|L)* {L}({L}|{D})* {yylval.string = new std::string(yytext); return(IDENTIFIER);} -0[xX]{H}+{IS}? {yylval.numberInt = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} -0{D}+{IS}? {yylval.numberInt = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} -{D}+{IS}? {yylval.numberInt = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} -L?'(\\.|[^\\'])+' {yylval.numberInt = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} +0[xX]{H}+{IS}? {yylval.number_int = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} +0{D}+{IS}? {yylval.number_int = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} +{D}+{IS}? {yylval.number_int = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} +L?'(\\.|[^\\'])+' {yylval.number_int = (int)strtol(yytext, NULL, 0); return(INT_CONSTANT);} -{D}+{E}{FS}? {yylval.numberFloat = strtod(yytext, NULL); return(FLOAT_CONSTANT);} -{D}*"."{D}+({E})?{FS}? {yylval.numberFloat = strtod(yytext, NULL); return(FLOAT_CONSTANT);} -{D}+"."{D}*({E})?{FS}? {yylval.numberFloat = strtod(yytext, NULL); return(FLOAT_CONSTANT);} +{D}+{E}{FS}? {yylval.number_float = strtod(yytext, NULL); return(FLOAT_CONSTANT);} +{D}*"."{D}+({E})?{FS}? {yylval.number_float = strtod(yytext, NULL); return(FLOAT_CONSTANT);} +{D}+"."{D}*({E})?{FS}? {yylval.number_float = strtod(yytext, NULL); return(FLOAT_CONSTANT);} L?\"(\\.|[^\\"])*\" {/* TODO process string literal */; return(STRING_LITERAL);} diff --git a/src/parser.y b/src/parser.y index b0e5a98..9dd1fe8 100644 --- a/src/parser.y +++ b/src/parser.y @@ -18,11 +18,11 @@ %union{ Node* node; - NodeList* nodeList; - int numberInt; - double numberFloat; + NodeList* node_list; + int number_int; + double number_float; std::string* string; - TypeSpecifier typeSpecifier; + TypeSpecifier type_specifier; yytokentype token; } @@ -39,12 +39,12 @@ %type equality_expression and_expression exclusive_or_expression inclusive_or_expression logical_and_expression logical_or_expression %type conditional_expression assignment_expression expression declarator direct_declarator statement compound_statement jump_statement -%type statement_list +%type statement_list -%type INT_CONSTANT STRING_LITERAL -%type FLOAT_CONSTANT +%type INT_CONSTANT STRING_LITERAL +%type FLOAT_CONSTANT %type IDENTIFIER -%type type_specifier declaration_specifiers +%type type_specifier declaration_specifiers %start ROOT