PPT Slide
import java_cup.runtime.*;
%%
%class lex
%cup
%standalone
%unicode
LineTerminator = \r|\n|\r\n
Slash = "/"
Field = [^/\r\n]+
%%
{Field} { return new Symbol(sym.FIELD, yytext()); }
{Slash} { return new Symbol(sym.SLASH); }
{LineTerminator} { return new Symbol(sym.EOL); }
<<EOF>> { return new Symbol(sym.EOF); }
mylexer.flex
See example15
Symbol (see below)
is in the runtime
package, so be sure
to do this import.
The cup directive
enables the parser to
receive the tokens
generated by this
lexer.
Return to the
parser a token,
FIELD, as well
as the value of
the token.
Return just the
token, SLASH.
Previous slide
Next slide
Back to first slide
View graphic version