-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavat.l
31 lines (29 loc) · 812 Bytes
/
javat.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
%option noyywrap
%{
#include <stdio.h>
#define YY_DECL int yylex()
#include "javat.tab.h"
%}
%%
[ \t] ; // ignore all space
"public" { return PUBLIC; }
"private" { return PRIVATE; }
"class" { return CLASS; }
[A-Za-z_] { yylval.string = strdup(yytext); return LETTER; }
[A-Za-z_]+[A-Za-z0-9_$]* { yylval.string = strdup(yytext); return WORD; }
[0-9]+\.[0-9]+ { yylval.floating = atof(yytext); return FLOAT; }
[0-9]+[A-Za-z_]+[A-Za-z0-9_$]* { return DISALLOWED_INDENTIFIER; }
[0-9]+ { yylval.number = atoi(yytext); return INT; }
";" { return SEMICOLON; }
"+" { return ADD; }
"-" { return SUBT; }
"*" { return MULT; }
"/" { return DIV; }
"(" { return LPAR; }
")" { return RPAR; }
"{" { return LBRACE; }
"}" { return RBRACE; }
\""" { return QUOTE; }
"=" { return EQUALS; }
"\n" { return NEW; }
%%