Archived
1
0
Fork 0

Updated token splitter to contain lambda notatoin

This commit is contained in:
Brandon Rozek 2018-09-28 15:28:47 -04:00
parent 7d044f5698
commit 7733f5b3c2

View file

@ -31,6 +31,8 @@
#define COMMENT 128 #define COMMENT 128
#define ERROR 129 #define ERROR 129
#define WHITESPACE 130 #define WHITESPACE 130
#define LAMBDA 131
#define COLON 132
%} %}
ALPHA [a-zA-Z] ALPHA [a-zA-Z]
DIGIT [0-9] DIGIT [0-9]
@ -44,7 +46,7 @@ DIGIT [0-9]
"(" {return OPENPAREM;} "(" {return OPENPAREM;}
")" {return ENDPAREM;} ")" {return ENDPAREM;}
";" {return SEMICOLON;} ";" {return SEMICOLON;}
%.*\n {return COMMENT;} %.*\n {} // Comments
"<" {return LESS;} "<" {return LESS;}
">" {return GREATER;} ">" {return GREATER;}
"<=" {return LESSEQ;} "<=" {return LESSEQ;}
@ -63,11 +65,17 @@ DIGIT [0-9]
"while" {return WHILE;} "while" {return WHILE;}
"print" {return PRINT;} "print" {return PRINT;}
"input" {return INPUT;} "input" {return INPUT;}
"lambda" {return LAMBDA;}
":" {return COLON;}
"true" {return VALUE;}
"false" {return VALUE;}
\".*\" {return VALUE; }
{DIGIT} {return VALUE;}
{DIGIT}*"."?{DIGIT}+ {return VALUE;} {DIGIT}*"."?{DIGIT}+ {return VALUE;}
[_a-zA-Z][_a-zA-Z0-9]* {return IDENTIFIER;} [_a-zA-Z][_a-zA-Z0-9]* {return IDENTIFIER;}
[ \n\t\r]+ {return WHITESPACE;} [\n] { }
. {printf("Syntax Error! Received: %s\n", yytext); return ERROR;} [ \t\r]+ {}
. {printf("Error: invlaid lexeme '%s'.\n", yytext); return 0;}
%% %%
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
if (argc != 2) { if (argc != 2) {