org.hecl
Class Parse

java.lang.Object
  extended by org.hecl.Parse
Direct Known Subclasses:
ParseList

public class Parse
extends java.lang.Object

The Parse class takes care of parsing Hecl scripts.

Version:
1.0
Author:
David N. Welton

Field Summary
protected  java.lang.String in
           
protected  Interp interp
           
protected  StringThing outBuf
           
protected  boolean outBufNumeric
           
protected  boolean outBufused
           
protected  java.util.Vector outGroup
           
protected  java.util.Vector outList
           
protected  boolean parselist
           
protected  ParseState state
           
 
Constructor Summary
Parse()
          Creates a new Parse instance.
Parse(Interp interp_in, java.lang.String in_in)
          Creates a new Parse instance.
 
Method Summary
protected  void addCommand()
          The addCommand method adds a command to the current output.
protected  void addCurrent()
          The addCurrent method adds a new element to the command parsed.
 void addDollar()
          The addDollar method adds a $var lookup to the current output.
 void addSub(int type)
           
protected  void appendToCurrent(char ch)
          The appendToCurrent method adds a character to the group object.
 boolean more()
          The more method returns a boolean value indicating whether there is more text to be parsed or not.
protected  void newCurrent()
          The newCurrent method creates a new 'context' to be added to.
 java.util.Vector parse()
          The parse method runs the parser on the text added by creating a new Parse instance.
protected  void parseBlock(ParseState state)
          parseBlock parses a {} block.
protected  void parseBlockOrCommand(ParseState state, boolean block, boolean invar)
          parseBlockOrCommand is what parseCommand and parseBlock use internally.
protected  void parseCommand(ParseState state)
          parseCommand parses a [] command.
protected  boolean parseEscape(ParseState state)
          The parseEscape method parses \n \t style escapes - or just prints the next character.
 void parseLine(ParseState state)
          The parseLine method is where parsing starts on a new line.
protected  void parseText(ParseState state)
          parseText parses a "string in quotes".
 CodeThing parseToCode()
          parseToCode parses up a [] section as code.
protected  void parseVarBlock(ParseState state)
           
protected  void parseWord(ParseState state)
          parseWord parses a regular word not in quotes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outList

protected java.util.Vector outList

state

protected ParseState state

interp

protected Interp interp

in

protected java.lang.String in

outBuf

protected StringThing outBuf

outBufNumeric

protected boolean outBufNumeric

outBufused

protected boolean outBufused

outGroup

protected java.util.Vector outGroup

parselist

protected boolean parselist
Constructor Detail

Parse

public Parse()
Creates a new Parse instance. Not actually used by anything.


Parse

public Parse(Interp interp_in,
             java.lang.String in_in)
Creates a new Parse instance.

Parameters:
interp_in - a Interp value
in_in - a String value
Method Detail

more

public boolean more()
The more method returns a boolean value indicating whether there is more text to be parsed or not.

Returns:
a boolean value

parse

public java.util.Vector parse()
                       throws HeclException
The parse method runs the parser on the text added by creating a new Parse instance.

Returns:
a Vector value
Throws:
HeclException - if an error occurs

parseToCode

public CodeThing parseToCode()
                      throws HeclException
parseToCode parses up a [] section as code.

Returns:
a CodeThing value
Throws:
HeclException - if an error occurs

newCurrent

protected void newCurrent()
                   throws HeclException
The newCurrent method creates a new 'context' to be added to.

Throws:
HeclException - if an error occurs

addCurrent

protected void addCurrent()
                   throws HeclException
The addCurrent method adds a new element to the command parsed.

Throws:
HeclException

appendToCurrent

protected void appendToCurrent(char ch)
                        throws HeclException
The appendToCurrent method adds a character to the group object.

Parameters:
ch - a char
Throws:
HeclException

addCommand

protected void addCommand()
                   throws HeclException
The addCommand method adds a command to the current output.

Throws:
HeclException - if an error occurs

addDollar

public void addDollar()
               throws HeclException
The addDollar method adds a $var lookup to the current output.

Throws:
HeclException - if an error occurs

addSub

public void addSub(int type)
            throws HeclException
Throws:
HeclException

parseLine

public void parseLine(ParseState state)
               throws HeclException
The parseLine method is where parsing starts on a new line.

Parameters:
state - a ParseState value
Throws:
HeclException - if an error occurs

parseBlock

protected void parseBlock(ParseState state)
                   throws HeclException
parseBlock parses a {} block.

Parameters:
state - a ParseState value
Throws:
HeclException - if an error occurs

parseVarBlock

protected void parseVarBlock(ParseState state)
                      throws HeclException
Throws:
HeclException

parseCommand

protected void parseCommand(ParseState state)
                     throws HeclException
parseCommand parses a [] command.

Parameters:
state - a ParseState value
Throws:
HeclException - if an error occurs

parseBlockOrCommand

protected void parseBlockOrCommand(ParseState state,
                                   boolean block,
                                   boolean invar)
                            throws HeclException
parseBlockOrCommand is what parseCommand and parseBlock use internally.

Parameters:
state - a ParseState value
block - a boolean value
Throws:
HeclException - if an error occurs

parseText

protected void parseText(ParseState state)
                  throws HeclException
parseText parses a "string in quotes".

Parameters:
state - a ParseState value
Throws:
HeclException - if an error occurs

parseWord

protected void parseWord(ParseState state)
                  throws HeclException
parseWord parses a regular word not in quotes.

Parameters:
state - a ParseState value
Throws:
HeclException - if an error occurs

parseEscape

protected boolean parseEscape(ParseState state)
                       throws HeclException
The parseEscape method parses \n \t style escapes - or just prints the next character.

Parameters:
state - a ParseState value
Returns:
a boolean value
Throws:
HeclException - if an error occurs