From 566d17f731637df6828bdf32502a0fb123882dbe Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Thu, 9 Oct 2003 11:41:45 +0000 Subject: Initial import --- .../directory/parser/DirectoryLexer.flex | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex (limited to 'src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex') diff --git a/src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex b/src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex new file mode 100644 index 0000000..91462a7 --- /dev/null +++ b/src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex @@ -0,0 +1,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] | \\ | \^ | [_-~])+ + +%% + + { + {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()+">"); } -- cgit v1.2.3