Updated token splitter to contain lambda notatoin
This commit is contained in:
parent
7d044f5698
commit
7733f5b3c2
1 changed files with 12 additions and 4 deletions
|
@ -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) {
|
||||||
|
|
Reference in a new issue