Skip to content

Commit

Permalink
Renamed parser types
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-staal committed Mar 4, 2024
1 parent af4ba88 commit c2b5042
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions src/lexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -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);}
Expand Down
16 changes: 8 additions & 8 deletions src/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -39,12 +39,12 @@
%type <node> equality_expression and_expression exclusive_or_expression inclusive_or_expression logical_and_expression logical_or_expression
%type <node> conditional_expression assignment_expression expression declarator direct_declarator statement compound_statement jump_statement

%type <nodeList> statement_list
%type <node_list> statement_list

%type <numberInt> INT_CONSTANT STRING_LITERAL
%type <numberFloat> FLOAT_CONSTANT
%type <number_int> INT_CONSTANT STRING_LITERAL
%type <number_float> FLOAT_CONSTANT
%type <string> IDENTIFIER
%type <typeSpecifier> type_specifier declaration_specifiers
%type <type_specifier> type_specifier declaration_specifiers


%start ROOT
Expand Down

0 comments on commit c2b5042

Please sign in to comment.