-
Notifications
You must be signed in to change notification settings - Fork 0
/
jfmrm.jflex
executable file
·75 lines (65 loc) · 3.13 KB
/
jfmrm.jflex
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package atividade1;
%%
/* Não altere as configurações a seguir */
%line
%column
%unicode
//%debug
%public
%standalone
%class Minijava
%eofclose
/* Insira as regras léxicas abaixo */
letter = [A-Za-z]
digit = [0-9]
integer = ([1-9][0-9]+)|(0[^\d])|([1-9])|0
alphanumeric = {letter}|{digit}
identifier = ({letter} | [_])({alphanumeric} | [_])*
whitespace = [ \n\t\r\f]
multilineComment= \/\*[A-Za-z .0-9_/\n/\t\/r\/f]*\*\/
lineComment = \/\/.*
%%
"&&" { System.out.println("Token &&"); }
"<" { System.out.println("Token <"); }
"==" { System.out.println("Token =="); }
"!=" { System.out.println("Token !="); }
"+" { System.out.println("Token +"); }
"-" { System.out.println("Token -"); }
"*" { System.out.println("Token *"); }
"!" { System.out.println("Token !"); }
";" { System.out.println("Token ;"); }
"." { System.out.println("Token ."); }
"," { System.out.println("Token ,"); }
"=" { System.out.println("Token ="); }
"(" { System.out.println("Token ("); }
")" { System.out.println("Token )"); }
"{" { System.out.println("Token {"); }
"}" { System.out.println("Token }"); }
"[" { System.out.println("Token ["); }
"]" { System.out.println("Token ]"); }
"boolean" { System.out.println("Token boolean"); }
"class" { System.out.println("Token class"); }
"public" { System.out.println("Token public"); }
"extends" { System.out.println("Token extends"); }
"static" { System.out.println("Token static"); }
"void" { System.out.println("Token void"); }
"main" { System.out.println("Token main"); }
"String" { System.out.println("Token String"); }
"int" { System.out.println("Token int"); }
"while" { System.out.println("Token while"); }
"if" { System.out.println("Token if"); }
"else" { System.out.println("Token else"); }
"return" { System.out.println("Token return"); }
"length" { System.out.println("Token length"); }
"true" { System.out.println("Token true"); }
"false" { System.out.println("Token false"); }
"this" { System.out.println("Token this"); }
"new" { System.out.println("Token new"); }
"System.out.println" { System.out.println("Token System.out.println"); }
{identifier} { System.out.println("Token ID ("+yytext()+")"); }
{whitespace} { /* ignore */}
{integer} { System.out.println("Token INT ("+yytext()+")"); }
{multilineComment} { /* ignore */}
{lineComment} { /* ignore */}
/* Insira as regras léxicas no espaço acima */
. { throw new RuntimeException("Caractere ilegal! '" + yytext() + "' na linha: " + yyline + ", coluna: " + yycolumn); }