diff --git a/lexicalStructure b/lexicalStructure deleted file mode 100755 index 8817fe4..0000000 Binary files a/lexicalStructure and /dev/null differ diff --git a/lexicalStructure.lex b/lexicalStructure.lex index dd5b71e..e1a70ee 100644 --- a/lexicalStructure.lex +++ b/lexicalStructure.lex @@ -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 ) );} -%% \ No newline at end of file +%%