Subversion Repositories programming

Rev

Rev 261 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*******************************************************************************
 * File: robot.flex
 *
 * Copyright (c) 2006, Ira W. Snyder (devel@irasnyder.com)
 * License: GNU General Public License v2
 *
 * This file implements the scanner that reads the input for
 * the robot from Project #3, Question #2.
 ******************************************************************************/

%%

%byaccj

%{
    /* store a reference to the Parser object */
    private Parser yyparser;

    /* constructor taking an additional Parser object */
    public Yylex(java.io.Reader r, Parser yyparser)
    {
        this(r);
        this.yyparser = yyparser;
    }
%}

WSPACE = [\ \t]+
NL     = \n | \r | \r\n
IGNORE = [^ptPT\ \t\n\r]+

%%

"p"         { return Parser.PUT;        }
"P"         { return Parser.PUT;        }
"t"         { return Parser.TAKE;       }
"T"         { return Parser.TAKE;       }
{NL}        { return Parser.NL;         }
{WSPACE}    {                           }
{IGNORE}    {                           }