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:
- Make a new instance of this class, giving the constructor
a reference to the stream you wish to parse.
- Call the StarFileNodeParse() method to
parse in a complete Star File.
- 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.)
-
doubleMarker
- marks the value as double-quote delimited
-
fieldDelim
- notes the start of a value's column num
-
framecodeMarker
- marks the value as framecode delimited
-
jj_nt
-
-
lineDelim
- notes the start of a line num
-
nonMarker
- marks the value as non delimited
-
prevLine
-
-
semicolonMarker
- marks the value as semicolon delimited
-
singleMarker
- marks the value as single-quote delimited
-
symbolBlockNode
-
-
symbolDataItemNode
-
-
symbolDataLoopNameListNode
-
-
symbolDataNameNode
-
-
symbolDataValueNode
-
-
symbolHomemadeStringBuffer
-
-
symbolLoopTableNode
-
-
symbolSaveFrameNode
-
-
symbolTinyAbsTypeName
-
-
token
-
-
token_source
-
-
StarParser(InputStream)
-
-
StarParser(Reader)
-
-
StarParser(StarParserTokenManager)
-
-
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.
-
DataItemNodeParse(StarParser)
- This method will parse a single DataItemNode.
-
DataLoopNameListNodeParse(StarParser)
-
-
DataLoopNodeParse(StarParser)
- This method will parse a single DataLoopNode.
-
DataNameNodeParse(StarParser)
- This method will parse a single DataNameNode (a tag).
-
DataNodeParse(StarParser)
- This method will parse either a single DataItemNode, or
a single DataLoopNode, or a single SaveFrameNode.
-
DataValueNodeParse(StarParser)
- This method will parse a single DataValueNode.
-
disable_tracing()
-
-
enable_tracing()
-
-
endResult()
- This method is depreciated and just is a call to
popResult().
-
EpsilonParse()
-
-
generateParseException()
-
-
getNextToken()
-
-
getNumValsInCurLoopAtLevel(int)
- Get the number of values that should be in one row
for the nesting level given for the most recently
parsed DataLoopNameListNode.
-
getToken(int)
-
-
LoopNameListNodeParse(StarParser)
-
-
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.
-
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.
-
LoopValuesParse(StarParser)
-
-
OptionalStopParse(StarParser)
-
-
popResult()
- Get the StarNode object that was created by the parse.
-
ReInit(InputStream)
-
-
ReInit(Reader)
-
-
ReInit(StarParserTokenManager)
-
-
SaveDataNodeParse(StarParser)
- This method will parse one of the items that is allowed inside
a SaveFrameNode.
-
SaveFrameNodeParse(StarParser)
- This method will parse a single SaveFrameNode.
-
setVerbose(int)
- Call this method before parsing to turn on some debugging
printing.
-
StarFileNodeParse(StarParser)
- This method will parse an entire star file.
-
StopParse(StarParser)
-
-
TinyAbsDataValueNodeParse(StarParser)
- This method will parse a single TinyAbsDataValueNode.
-
trimToSize()
- Trim the stack after a big deletion.
prevLine
public static int prevLine
symbolTinyAbsTypeName
public static String symbolTinyAbsTypeName
symbolDataValueNode
public static String symbolDataValueNode
symbolDataNameNode
public static String symbolDataNameNode
symbolDataItemNode
public static String symbolDataItemNode
symbolBlockNode
public static String symbolBlockNode
symbolSaveFrameNode
public static String symbolSaveFrameNode
symbolHomemadeStringBuffer
public static String symbolHomemadeStringBuffer
symbolLoopTableNode
public static String symbolLoopTableNode
symbolDataLoopNameListNode
public static String symbolDataLoopNameListNode
lineDelim
public static char lineDelim
- notes the start of a line num
fieldDelim
public static char fieldDelim
- notes the start of a value's column num
singleMarker
public static char singleMarker
- marks the value as single-quote delimited
doubleMarker
public static char doubleMarker
- marks the value as double-quote delimited
semicolonMarker
public static char semicolonMarker
- marks the value as semicolon delimited
framecodeMarker
public static char framecodeMarker
- marks the value as framecode delimited
nonMarker
public static char nonMarker
- marks the value as non delimited
token_source
public static StarParserTokenManager token_source
token
public static Token token
jj_nt
public static Token jj_nt
StarParser
public StarParser(InputStream stream)
StarParser
public StarParser(Reader stream)
StarParser
public StarParser(StarParserTokenManager tm)
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.)
endResult
public StarNode endResult()
- This method is depreciated and just is a call to
popResult(). Please use popResult() instead
in future coding projects.
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.)
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.)
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.
EpsilonParse
public static final void EpsilonParse() throws ParseException
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.
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'.)
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'.)
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'.)
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'.)
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'.)
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'.)
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'.)
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'.)
LoopValuesParse
public static final void LoopValuesParse(StarParser p) throws ParseException
StopParse
public static final void StopParse(StarParser p) throws ParseException
OptionalStopParse
public static final void OptionalStopParse(StarParser p) throws ParseException
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.
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.
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'.)
DataLoopNameListNodeParse
public static final void DataLoopNameListNodeParse(StarParser p) throws ParseException
LoopNameListNodeParse
public static final void LoopNameListNodeParse(StarParser p) throws ParseException
ReInit
public static void ReInit(InputStream stream)
ReInit
public static void ReInit(Reader stream)
ReInit
public void ReInit(StarParserTokenManager tm)
getNextToken
public static final Token getNextToken()
getToken
public static final Token getToken(int index)
generateParseException
public static final ParseException generateParseException()
enable_tracing
public static final void enable_tracing()
disable_tracing
public static final void disable_tracing()
All Packages Class Hierarchy This Package Previous Next Index