Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.metacosm.framework.parser
Class Parser  view Parser download Parser.java

java.lang.Object
  extended byorg.metacosm.framework.parser.Parser

public final class Parser
extends java.lang.Object

The Parser is used to parse (!) input streams from players. It's also a Singleton OOD pattern. The following grammar is accepted: input::= pseudocmd ([;] pseudocmd)* pseudocmd::= (white)* command (white)* white::= [space] command::= cmdname (pseudoparam)* | (white)* pseudoparam::= white (white)* param param ::= [alphanum] ([alphanum])* | ['] [alphanum] ([alphanum])* ['] Terminal symbol: [space] (space), [;] (commands delimiter), ['] (string delimiter], [alphanum] (others autorized characters)


Field Summary
private static java.lang.String cmd_delim
          Character used to separe commands
private static java.lang.String delimiters
          Characters used to separe tokens Default is space, cmd_delim and str_delim.
private static Parser parser
          The instance of the class.
private static java.lang.String str_delim
          Character used to delimit a string
 
Constructor Summary
private Parser()
          The constructor is private because of singleton pattern.
 
Method Summary
static Parser getInstance()
           
(package private)  boolean isPlayerCommand(java.lang.String cmdName)
          Tests if a command is a PlayerCommand or a ControllerCommand.
private  java.lang.String junkWhites(java.util.StringTokenizer st)
          Junks leading whites.
 java.lang.String parse(org.metacosm.framework.server.Player player, java.lang.String input)
          Parses and executes the first command found in a string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parser

private static Parser parser
The instance of the class.


delimiters

private static java.lang.String delimiters
Characters used to separe tokens Default is space, cmd_delim and str_delim.

See Also:
cmd_delim, str_delim

str_delim

private static java.lang.String str_delim
Character used to delimit a string


cmd_delim

private static java.lang.String cmd_delim
Character used to separe commands

Constructor Detail

Parser

private Parser()
The constructor is private because of singleton pattern. Sets the command and string delimiters from configuration file. Throws exceptions if incorrect delimiters.

Method Detail

getInstance

public static Parser getInstance()

parse

public java.lang.String parse(org.metacosm.framework.server.Player player,
                              java.lang.String input)
Parses and executes the first command found in a string. An exception is thrown if something goes wrong.


junkWhites

private java.lang.String junkWhites(java.util.StringTokenizer st)
Junks leading whites.


isPlayerCommand

boolean isPlayerCommand(java.lang.String cmdName)
Tests if a command is a PlayerCommand or a ControllerCommand. Throws exception in other cases.