org.pz.platypus.parsers
Class MacroParser

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

public class MacroParser
extends java.lang.Object

Parses macros and looks them up in the macro tables. TODO: need to handle multiple layers of macros and check for circular macros.

Author:
alb

Field Summary
private  GDD gdd
          following are for output of error messages
 
Constructor Summary
MacroParser(GDD gdd)
           
 
Method Summary
 java.lang.String extractMacroName(char[] input, int parsePoint)
          Extract the macro name from the string of chars starting at parsePoint
 java.lang.String lookupSystemMacro(java.lang.String macro)
          Look up a macro in the table of System stings
 int parse(char[] input, int parsePoint)
          Principal function.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gdd

private GDD gdd
following are for output of error messages

Constructor Detail

MacroParser

public MacroParser(GDD gdd)
Method Detail

parse

public int parse(char[] input,
                 int parsePoint)
Principal function. Extracts the macro name and looks it up. It dumps the expanded text into the expandedMacro parameter and returns the number of chars parsed in the input text.

Parameters:
input - the input Platypus text that contains a macro
parsePoint - where to start parsing input
Returns:
the number of chars to move the isLineComment point forward

lookupSystemMacro

public java.lang.String lookupSystemMacro(java.lang.String macro)
Look up a macro in the table of System stings

Parameters:
macro - macro to look up
Returns:
expanded macro from the table; null, if an error occurred

extractMacroName

public java.lang.String extractMacroName(char[] input,
                                         int parsePoint)
                                  throws java.lang.IllegalArgumentException
Extract the macro name from the string of chars starting at parsePoint

Parameters:
input - the chars from which to extract the macro. should begin with a $
parsePoint - the point in input where the extracting should begin
Returns:
the macro name if all went well; null, if not.
Throws:
java.lang.IllegalArgumentException - in the event an invalid macro name was used


Copyright © 2008-10 Pacific Data Works LLC