org.pz.platypus.parsers
Class CommandFamilyParser

java.lang.Object
  extended by org.pz.platypus.parsers.CommandFamilyParser

public class CommandFamilyParser
extends java.lang.Object

Handles parsing of compound commands

Author:
alb

Constructor Summary
CommandFamilyParser()
           
 
Method Summary
(package private)  java.lang.String extractCommandName(char[] content, int parsePoint)
          return a command name in a complex command; e.g.
(package private)  void fixUp(TokenList tokens, ParseContext context, int end)
          Complex commands can have 1 or more commands.
private  void invalidCommandError(GDD gdd, ParseContext context, java.lang.String command)
          Outputs the error info to the user console
private  void invalidParameterError(GDD gdd, ParseContext context, java.lang.String command)
          Outputs the error info to the user console
 int parse(CommandTable ctable, ParseContext context, TokenList parsedTokens, java.lang.String familyRoot, GDD gdd)
          Parses a compound command, extracting the next command (as pointed to in the ParseContext) and any parameters associated with the command.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandFamilyParser

public CommandFamilyParser()
Method Detail

parse

public int parse(CommandTable ctable,
                 ParseContext context,
                 TokenList parsedTokens,
                 java.lang.String familyRoot,
                 GDD gdd)
Parses a compound command, extracting the next command (as pointed to in the ParseContext) and any parameters associated with the command.

Parameters:
ctable - map of all commands
context - the parsing context
parsedTokens - the output list of tokens generated by the isLineComment
familyRoot - the root of the command family = [font|
gdd - GDD
Returns:
the number of characters processsed
Throws:
InvalidCommandException - if the command cannot be found
InvalidCommandParameterException - if the parameter is invalid
java.lang.IllegalArgumentException - if an invalid arg is passed to the method

fixUp

void fixUp(TokenList tokens,
           ParseContext context,
           int end)
Complex commands can have 1 or more commands. If it's just 1, this routine converts it into a simple command. Otherwise, it's a complex command and the opening and closing tokens are added to the token list.

Parameters:
tokens - list of parsed commands
context - the parser context
end - the end point in the input

extractCommandName

java.lang.String extractCommandName(char[] content,
                                    int parsePoint)
return a command name in a complex command; e.g. "size" in [font|size=12pt]

Parameters:
content - the input we're parsing
parsePoint - where to start the isLineComment
Returns:
a string consisting of the command, or null on error.

invalidCommandError

private void invalidCommandError(GDD gdd,
                                 ParseContext context,
                                 java.lang.String command)
Outputs the error info to the user console

Parameters:
gdd - the GDD, used for the logger
context - where the error occurred
command - the errant command

invalidParameterError

private void invalidParameterError(GDD gdd,
                                   ParseContext context,
                                   java.lang.String command)
Outputs the error info to the user console

Parameters:
gdd - the GDD, used for the logger
context - where the error occurred
command - the command withe the errant parameter


Copyright © 2008-10 Pacific Data Works LLC