-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcocolJava.txt
More file actions
106 lines (95 loc) · 2.35 KB
/
cocolJava.txt
File metadata and controls
106 lines (95 loc) · 2.35 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
COMPILER LexerAnalyzer
CHARACTERS
tab = CHR(09).
lf = CHR(10).
cr = CHR(13).
zero = '0'.
zeroToThree = zero + "123" .
octalDigit = zero + "1234567" .
nonZeroDigit = "123456789".
digit = '0' + nonZeroDigit .
hexDigit = digit + "ABCDEFabcdef" .
letter = 'A' .. 'Z' + 'a' .. 'z' + '$'.
some_chars = CHR(33)..CHR(39).
escape_chars = some_chars + "\\".
char = ANY - "'" - "\\" - cr - lf.
stringChar = ANY - "\"" - "\\"- cr - lf.
KEYWORDS
if = "if".
while = "while".
boolean = "boolean".
byte = "byte".
char = "char".
class = "class".
double = "double".
false = "false".
final = "final".
float = "float".
int = "int".
long = "long".
new = "new".
null = "null".
short = "short".
static = "static".
super = "super".
this = "this".
true = "true".
void = "void".
colon = ":".
comma = ",".
dec = "--".
dot = ".".
inc = "++".
lbrace = "{".
lbrack = "[".
lpar = "(".
minus = "-".
not = "!".
plus = "+".
rbrace = "}".
rbrack = "]".
rpar = ")".
tilde = "~".
igual = "=".
TOKENS
letter = letter{letter} EXCEPT KEYWORDS.
ident1 = letter {'_'} '*'.
number = digit {digit}
| digit {digit} '.' {digit} ['E' ['+'|'-'] digit {digit}].
intLit =
( zero | nonZeroDigit { digit }
| ( "0x" | "0X" ) hexDigit { hexDigit }
| '0' octalDigit { octalDigit }
) [ "l" | "L" ].
charLit =
"'" ( char
| "\\" ( "b" | "t" | "n" | "f" | "r" | "\"" | "\'" | "\\"
| "u" { "u" } hexDigit hexDigit hexDigit hexDigit
| zeroToThree [ octalDigit ] [ octalDigit ]
| octalDigit [ octalDigit ]
)
)
"'".
stringLit =
"\"" { stringChar
| "\\" ( "b" | "t" | "n" | "f" | "r" | "\"" | "\'" | "\\"
| "u" { "u" } hexDigit hexDigit hexDigit hexDigit
| zeroToThree [ octalDigit ] [ octalDigit ]
| octalDigit [ octalDigit ]
)
}
"\"" EXCEPT KEYWORDS.
floatLit =
"." digit {digit}
[("e" | "E") ["+" | "-"] digit {digit}]
[ "F" | "f" | "D" | "d" ]
| digit {digit}
( "." {digit}
[("e" | "E" ) ["+" | "-"] digit {digit} ]
[ "F" | "f" | "D" | "d" ]
| ("e" | "E") ["+" | "-"] digit {digit}
[ "F" | "f" | "D" | "d" ]
| "F" | "f" | "D" | "d"
).
IGNORE " ".
END LexerAnalyzer.