Building Parsers with Java

sjm.examples.robot
Class RobotParser

java.lang.Object
  |
  +--sjm.examples.robot.RobotParser

public class RobotParser
extends java.lang.Object

This class's start() method provides a parser that will recognize a command for a track robot and build a corresponding command object.

The grammar for the language that this class recognizes is:

     command      = pickCommand | placeCommand | 
                    scanCommand;
     pickCommand  = "pick" "carrier" "from" location;
     placeCommand = "place" "carrier" "at" location;
     scanCommand  = "scan" location;
     location     = Word; 
 


Constructor Summary
RobotParser()
           
 
Method Summary
 Parser command()
          Returns a parser that will recognize a command for a track robot and build a corresponding command object.
protected  Parser location()
           
protected  Parser pickCommand()
           
protected  Parser placeCommand()
           
protected  Parser scanCommand()
           
static Parser start()
          Returns a parser that will recognize a command for a track robot and build a corresponding command object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RobotParser

public RobotParser()
Method Detail

command

public Parser command()
Returns a parser that will recognize a command for a track robot and build a corresponding command object. (This method returns the same value as start()).
Returns:
a parser that will recognize a track robot command

location

protected Parser location()

pickCommand

protected Parser pickCommand()

placeCommand

protected Parser placeCommand()

scanCommand

protected Parser scanCommand()

start

public static Parser start()
Returns a parser that will recognize a command for a track robot and build a corresponding command object.
Returns:
a parser that will recognize a track robot command

by Steve Metsker