Merge pull request #4 from UB-CSE443/Sprint1-Type/Keywards-FE-t#07

Sprint1 type/keywards fe t#07
This commit is contained in:
maxsimongt3
2025-02-11 16:55:19 -05:00
committed by GitHub
2 changed files with 22 additions and 2 deletions

Binary file not shown.

View File

@ -7,7 +7,7 @@
%{
#include "typedefs.h"
%}
int line_number = 1, column_number = 1;
DIGIT [0-9]
CHAR \\n|\\t|\\'|[^'\n\t\\]
@ -21,15 +21,35 @@ COMMENTCHAR [^\*]|\*[^\)]
%%
\n line_number++ column_number = 1;
. column_number++;
"integer" {return T_INTEGER}
"address" {return T_ADDRESS}
"Boolean" {return T_BOOLEAN}
"character" {return T_CHARACTER}
/* rules */
{DIGIT}+ {printf( "C_INTEGER: %s (%d)\n", yytext, atoi( yytext ) );}
"null" {printf( "C_NULL: %s (%d)\n", yytext, atoi( yytext ) );}
"while" {return WHILE}
"if" {return IF}
"then" {return THEN}
"else" {return ELSE}
"type" {return TYPE}
"function" {return FUNCTION}
"return" {return RETURN}
"external" {return EXTERNAL}
"as" {return AS}
'{CHAR}' {printf( "C_CHARACTER: %s (%d)\n", yytext, atoi( yytext ) );} /*using double \ per documentation to show escaped chars*/
"true" {printf( "C_TRUE: %s (%d)\n", yytext, atoi( yytext ) );}
"false" {printf( "C_FALSE: %s (%d)\n", yytext, atoi( yytext ) );}
/* OPERATORS */
@ -55,4 +75,4 @@ COMMENTCHAR [^\*]|\*[^\)]
{STARTCOM}{COMMENTCHAR}*{ENDCOM} {printf( "COMMENT: %s (%d)\n", yytext, atoi( yytext ) );}
%%
%%