All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class EDU.bmrb.starlibj.StarParser

java.lang.Object
   |
   +----EDU.bmrb.starlibj.StarParser

public class StarParser
extends Object
implements StarParserConstants
This is the class that is used to parse a Star File. This class was generated by the javacc tool from Sun. To parse an input file or stream, do these steps:

  1. Make a new instance of this class, giving the constructor a reference to the stream you wish to parse.

  2. Call the StarFileNodeParse() method to parse in a complete Star File.

  3. Call that object's endResult() method to see the final result of the parse (a StarFileNode).

Here is an example code fragment implementing the above steps:

     StarParser   aParser;
     StarFileNode aStarTree;
     String       fileName = "sample.str";
     try
     {
         aParser = new StarParser(
                          new java.io.FileInputStream(fileName) );
         aParser.StarFileNodeParse( aParser );
                       // 'aParser' needs to be sent as a
                       // parameter because javacc makes
                       // static methods that have no 'this'.
         aStarTree = aParser.endResult();
     }
     // (catch() clauses left off to keep the example brief.)
 

Note that is is possible to parse in a smaller subset of the STAR syntax if you are reading from a source that you know is not a complete STAR file. For example, you might want to parse a file that contains only a single SaveFrameNode that was cut from a larger file. To do this, use the appropriate ...Parse() method that goes with the name of the node you are trying to parse. To parse a save frame, use SaveFrameNodeParse(). To parse a loop, use DataLoopNodeParse(), and so on. Regardless of which Parse() method you call, the result is always found by called endResult(). (Which is essentially showing what is at the top of the parse stack after parsing completed.)

To parse multiple files, You must call StarParser.ReInit() between parses, even if you make a new StarParser object. This is because the input stream in StarParse is handled using internal static variables.

StarParser is not thread safe. You should only run one StarParser at a time. Again, this is because of the shared static data in the class. (This is fixable, but only if we create our own handmade stream-like class that implements the interface javacc wants to see and then use that instead of one of the standard java stream classes. When we try to tell javacc to make a non-static parser, it refuses to run on java.io.* stream classes.)


Variable Index

 o doubleMarker
marks the value as double-quote delimited
 o fieldDelim
notes the start of a value's column num
 o framecodeMarker
marks the value as framecode delimited
 o jj_nt
 o lineDelim
notes the start of a line num
 o nonMarker
marks the value as non delimited
 o prevLine
 o semicolonMarker
marks the value as semicolon delimited
 o singleMarker
marks the value as single-quote delimited
 o symbolBlockNode
 o symbolDataItemNode
 o symbolDataLoopNameListNode
 o symbolDataNameNode
 o symbolDataValueNode
 o symbolHomemadeStringBuffer
 o symbolLoopTableNode
 o symbolSaveFrameNode
 o symbolTinyAbsTypeName
 o token
 o token_source

Constructor Index

 o StarParser(InputStream)
 o StarParser(Reader)
 o StarParser(StarParserTokenManager)

Method Index

 o BlockNodeParse(StarParser)
This method will parse a single BlockNode (a global_ or data_ block.) You can get to it by calling endResult() after it finishes.
 o DataItemNodeParse(StarParser)
This method will parse a single DataItemNode.
 o DataLoopNameListNodeParse(StarParser)
 o DataLoopNodeParse(StarParser)
This method will parse a single DataLoopNode.
 o DataNameNodeParse(StarParser)
This method will parse a single DataNameNode (a tag).
 o DataNodeParse(StarParser)
This method will parse either a single DataItemNode, or a single DataLoopNode, or a single SaveFrameNode.
 o DataValueNodeParse(StarParser)
This method will parse a single DataValueNode.
 o disable_tracing()
 o enable_tracing()
 o endResult()
This method is depreciated and just is a call to popResult().
 o EpsilonParse()
 o generateParseException()
 o getNextToken()
 o getNumValsInCurLoopAtLevel(int)
Get the number of values that should be in one row for the nesting level given for the most recently parsed DataLoopNameListNode.
 o getToken(int)
 o LoopNameListNodeParse(StarParser)
 o LoopRowNodeParse(StarParser, LoopTableNode, int)
This method parses a single row of values, presuming that the DataLoopNameListNode has already been parsed and is on the stack underneath the current position.
 o LoopTableNodeParse(StarParser, int)
This method parses a table of values, presuming that the DataLoopNameListNode has already been properly parsed to hold the numbers of values in each nesting level.
 o LoopValuesParse(StarParser)
 o OptionalStopParse(StarParser)
 o popResult()
Get the StarNode object that was created by the parse.
 o ReInit(InputStream)
 o ReInit(Reader)
 o ReInit(StarParserTokenManager)
 o SaveDataNodeParse(StarParser)
This method will parse one of the items that is allowed inside a SaveFrameNode.
 o SaveFrameNodeParse(StarParser)
This method will parse a single SaveFrameNode.
 o setVerbose(int)
Call this method before parsing to turn on some debugging printing.
 o StarFileNodeParse(StarParser)
This method will parse an entire star file.
 o StopParse(StarParser)
 o TinyAbsDataValueNodeParse(StarParser)
This method will parse a single TinyAbsDataValueNode.
 o trimToSize()
Trim the stack after a big deletion.

Variables

 o prevLine
 public static int prevLine
 o symbolTinyAbsTypeName
 public static String symbolTinyAbsTypeName
 o symbolDataValueNode
 public static String symbolDataValueNode
 o symbolDataNameNode
 public static String symbolDataNameNode
 o symbolDataItemNode
 public static String symbolDataItemNode
 o symbolBlockNode
 public static String symbolBlockNode
 o symbolSaveFrameNode
 public static String symbolSaveFrameNode
 o symbolHomemadeStringBuffer
 public static String symbolHomemadeStringBuffer
 o symbolLoopTableNode
 public static String symbolLoopTableNode
 o symbolDataLoopNameListNode
 public static String symbolDataLoopNameListNode
 o lineDelim
 public static char lineDelim
notes the start of a line num

 o fieldDelim
 public static char fieldDelim
notes the start of a value's column num

 o singleMarker
 public static char singleMarker
marks the value as single-quote delimited

 o doubleMarker
 public static char doubleMarker
marks the value as double-quote delimited

 o semicolonMarker
 public static char semicolonMarker
marks the value as semicolon delimited

 o framecodeMarker
 public static char framecodeMarker
marks the value as framecode delimited

 o nonMarker
 public static char nonMarker
marks the value as non delimited

 o token_source
 public static StarParserTokenManager token_source
 o token
 public static Token token
 o jj_nt
 public static Token jj_nt

Constructors

 o StarParser
 public StarParser(InputStream stream)
 o StarParser
 public StarParser(Reader stream)
 o StarParser
 public StarParser(StarParserTokenManager tm)

Methods

 o popResult
 public StarNode popResult()
Get the StarNode object that was created by the parse. When the parse is complete, if no exceptions were thrown, then this method will return the object that was parsed. The object parsed is the last thing left on the stack. This method will also pop the object off the stack, so only the first call to this method after a parse will work properly. This was necessary to accomodate the Java garbage collector (Otherwise the reference to the item on the top of the stack would live forever and therefore the thing that was parsed (typically a StarFileNode) and all its children would remain in memory forever.)

 o endResult
 public StarNode endResult()
This method is depreciated and just is a call to popResult(). Please use popResult() instead in future coding projects.

 o setVerbose
 public void setVerbose(int verboseNum)
Call this method before parsing to turn on some debugging printing. Mostly this is for internal debugging.

Parameters:
verboseNum - = set to higher numbers for more info, (0 = silent) (Default is false when a StarParser is constructed.)
 o trimToSize
 public void trimToSize()
Trim the stack after a big deletion. Normally there is a lot of overhead in a Vector and it doesn't go away when the elements are removed. The capacity remains large long after the elements are no longer in use. This enforces the throwing away of the deleted elements: Do not call this method while the stack is still expected to grow bigger or it will make things execute very slowly. (This method removes all overhead room from the stack so that on the next insertion it will have to reallocate space again.) For best results, this method is only called when a large deletion from the stack has just been done (for example, a loop node was just made and all the values in it just got popped.)

 o getNumValsInCurLoopAtLevel
 public int getNumValsInCurLoopAtLevel(int nest)
Get the number of values that should be in one row for the nesting level given for the most recently parsed DataLoopNameListNode. This is the count of the number of DataNameNodes at that nesting level, for the DataLoopNameListNode that is closest to the top of the stack. Returns 0 if there is no such nesting level or no such previous loop on the stack.

 o EpsilonParse
 public static final void EpsilonParse() throws ParseException
 o StarFileNodeParse
 public static final void StarFileNodeParse(StarParser p) throws ParseException
This method will parse an entire star file. You can get to it by calling popResult() after it finishes.

 o BlockNodeParse
 public static final void BlockNodeParse(StarParser p) throws ParseException
This method will parse a single BlockNode (a global_ or data_ block.) You can get to it by calling endResult() after it finishes.

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o DataNodeParse
 public static final void DataNodeParse(StarParser p) throws ParseException
This method will parse either a single DataItemNode, or a single DataLoopNode, or a single SaveFrameNode. You can get to it by calling endResult() after it finishes. You will need to use the type-aware features of Java in java.lang.Class in order to figure out which of these three kinds of node was returned in endResult().

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o DataItemNodeParse
 public static final void DataItemNodeParse(StarParser p) throws ParseException
This method will parse a single DataItemNode. You can get to it by calling endResult() after it finishes.

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o DataNameNodeParse
 public static final void DataNameNodeParse(StarParser p) throws ParseException
This method will parse a single DataNameNode (a tag). You can get to it by calling endResult() after it finishes.

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o TinyAbsDataValueNodeParse
 public static final void TinyAbsDataValueNodeParse(StarParser p) throws ParseException
This method will parse a single TinyAbsDataValueNode. You can get to it by calling endResult() after it finishes.

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o DataValueNodeParse
 public static final void DataValueNodeParse(StarParser p) throws ParseException
This method will parse a single DataValueNode. You can get to it by calling endResult() after it finishes.

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o SaveFrameNodeParse
 public static final void SaveFrameNodeParse(StarParser p) throws ParseException
This method will parse a single SaveFrameNode. You can get to it by calling endResult() after it finishes.

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o SaveDataNodeParse
 public static final void SaveDataNodeParse(StarParser p) throws ParseException
This method will parse one of the items that is allowed inside a SaveFrameNode. (Either a single DataItemNode, or a single DataLoopNode.) You can get to it by calling endResult() after it finishes. You will need to use the type-aware features of Java in java.lang.Class in order to figure out which of these three kinds of node was returned in endResult().

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o LoopValuesParse
 public static final void LoopValuesParse(StarParser p) throws ParseException
 o StopParse
 public static final void StopParse(StarParser p) throws ParseException
 o OptionalStopParse
 public static final void OptionalStopParse(StarParser p) throws ParseException
 o LoopTableNodeParse
 public static final void LoopTableNodeParse(StarParser p,
                                             int nest) throws ParseException
This method parses a table of values, presuming that the DataLoopNameListNode has already been properly parsed to hold the numbers of values in each nesting level.

 o LoopRowNodeParse
 public static final void LoopRowNodeParse(StarParser p,
                                           LoopTableNode tbl,
                                           int nest) throws ParseException
This method parses a single row of values, presuming that the DataLoopNameListNode has already been parsed and is on the stack underneath the current position.

 o DataLoopNodeParse
 public static final void DataLoopNodeParse(StarParser p) throws ParseException
This method will parse a single DataLoopNode. You can get to it by calling endResult() after it finishes.

Parameters:
p - It is necessary to pass the StarParser object itself because when javacc generates this source code, it generates this method with static scope (hence it has no concept of 'this'.)
 o DataLoopNameListNodeParse
 public static final void DataLoopNameListNodeParse(StarParser p) throws ParseException
 o LoopNameListNodeParse
 public static final void LoopNameListNodeParse(StarParser p) throws ParseException
 o ReInit
 public static void ReInit(InputStream stream)
 o ReInit
 public static void ReInit(Reader stream)
 o ReInit
 public void ReInit(StarParserTokenManager tm)
 o getNextToken
 public static final Token getNextToken()
 o getToken
 public static final Token getToken(int index)
 o generateParseException
 public static final ParseException generateParseException()
 o enable_tracing
 public static final void enable_tracing()
 o disable_tracing
 public static final void disable_tracing()

All Packages  Class Hierarchy  This Package  Previous  Next  Index