blob: 91462a7c5d0fa236ee2a4f6eee59644006a8b263 (
plain)
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
|
package org.noreply.fancydress.directory.parser;
import java_cup.runtime.*;
%%
%class DirectoryLexer
%public
%line
%column
%cupsym DirectorySymbols
%cup
%{
private Symbol symbol(int type) {
return new Symbol(type, yyline, yycolumn);
}
private Symbol symbol(int type, Object value) {
return new Symbol(type, yyline, yycolumn, value);
}
%}
Space = [ \t]+
Identifier = ([!-9] | [;-Z] | \\ | \^ | [_-~])+
%%
<YYINITIAL> {
{Space} { return symbol(DirectorySymbols.SPACE, new String(yytext())); }
"[" { return symbol(DirectorySymbols.LEFT_BRACKET, new String(yytext())); }
"]" { return symbol(DirectorySymbols.RIGHT_BRACKET, new String(yytext())); }
"\n" { return symbol(DirectorySymbols.NL); }
"\r" { return symbol(DirectorySymbols.CR); }
":" { return symbol(DirectorySymbols.COLON, new String(yytext())); }
{Identifier} { return symbol(DirectorySymbols.IDENTIFIER, new String(yytext())); }
}
[^] { throw new Error("Illegal character <"+yytext()+">"); }
|