summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex
blob: b44cf3c766bdb1d2907244d8bb01193200c3d203 (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
41
/* $Id$ */
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()+">"); }