diff options
Diffstat (limited to 'src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex')
-rw-r--r-- | src/org/noreply/fancydress/directory/parser/DirectoryLexer.flex | 40 |
1 files changed, 40 insertions, 0 deletions
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] | \\ | \^ | [_-~])+ + +%% + +<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()+">"); } |