-
Notifications
You must be signed in to change notification settings - Fork 0
/
BottleCap.l
36 lines (29 loc) · 844 Bytes
/
BottleCap.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
%option noyywrap
%{
#include <stdio.h>
#include <string.h>
#define YY_DECL int yylex()
#include "y.tab.h"
%}
%%
[ \t] ; // ignore all whitespace
[0-9][0-9]* {yylval.INT = atoi(yytext) ; return T_INT;}
"+" {return T_PLUS;}
"-" {return T_MINUS;}
"*" {return T_MULTIPLY;}
"/" {return T_DIVIDE;}
"Print" {return PRINT;}
"%" {return T_MOD;}
"Add" {return ADD;}
"Assign" {return ASSIGN;}
"Subtract" {return SUB;}
"Multiply" {return MUL;}
"Divide" {return DIV;}
"by" {return BY;}
"from" {return FROM;}
"to" {return TO;}
"with" {return WITH;}
\n {return T_NEWLINE;}
[a-zA-Z][a-zA-Z0-9]* {strcpy(yylval.str , yytext) ;return T_ID;}
. {yyerror("Invalid Syntex!") ;}
%%