byucc.jhdl.util.xmac
Class TagParser

java.lang.Object
  extended bybyucc.jhdl.util.xmac.TagParser
Direct Known Subclasses:
ClassParser, ClockParser, CodeParser, ConstructorParser, InterfaceParser, JavadocParser, LicenseParser, MethodParser, PackageParser, PropagateParser, ResetParser, SchematicParser, SharecellParser, StructureParser, TestParser, TextParser, WireMethodsParser, WireParser, XMACParser

public class TagParser
extends java.lang.Object

This is the generic xmac tag parser. The idea is to make xmac as open and extensible as possible. If you have a custom tag that needs to be processed then extend this class. In particular, the parse method needs to be overridden with your custom parsing proceedures.

Author:
Isaac E. Wagner

Field Summary
protected  DocInfo docInfo
          This object is passed back and forth between all the classes.
 
Constructor Summary
TagParser(DocInfo docInfo)
          Constructor.
 
Method Summary
protected  boolean checkParent(org.w3c.dom.Node node, java.lang.String name)
          Check a tag to see if it has the right parent.
protected  int countLines(java.lang.String text)
          Count the number of lines in a given text block.
protected  void decreaseIndent()
          Decrease the indent level of the output java code.
protected  void increaseIndent()
          Increase the indent level of the output java code.
protected  java.lang.String[] indentBlock(java.lang.String text)
          This takes a large block of text, possibly containing multiple lines, splits it up, then attempts to indent of of the lines to make good looking code.
protected  java.lang.String indentLine(java.lang.String text)
          Take a single line of text and indent it to the proper lever for the code.
protected  java.lang.String indentLine(java.lang.String text, int level, int spacesPerLevel)
          Take a single line of text and indent it to the proper lever for the code.
protected  void outmsg(java.lang.String text)
          Output a string to the user.
 void parse(org.w3c.dom.Node docRoot)
          This is the parser method to override.
 void parse(java.lang.String text)
          An alternate parse method if needed.
protected  java.lang.String[] strBlockToArray(java.lang.String text)
          Take a single long string containing multiple lines and turn it into an array of strings.
protected  void writeOutput(java.lang.String text)
          Write some text to the output file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

docInfo

protected DocInfo docInfo
This object is passed back and forth between all the classes. It holds all important information about the document.

Constructor Detail

TagParser

public TagParser(DocInfo docInfo)
          throws java.lang.Exception
Constructor. Takes as arguments the object that contains the document information, and the DOM Element that's the base of our little tree to process.

Parameters:
docInfo - The DocInfo object the holds data about the current class.
Method Detail

parse

public void parse(org.w3c.dom.Node docRoot)
           throws java.lang.Exception
This is the parser method to override.

Parameters:
docRoot - The Node of the little tree to process.
Returns:
None
Throws:
java.lang.Exception

parse

public void parse(java.lang.String text)
           throws java.lang.Exception
An alternate parse method if needed.

Parameters:
text - A String that the particular parser needs.
Returns:
None
Throws:
java.lang.Exception

strBlockToArray

protected java.lang.String[] strBlockToArray(java.lang.String text)
Take a single long string containing multiple lines and turn it into an array of strings.

Parameters:
text - The large String to chop into lines.
Returns:
An array of strings.

indentBlock

protected java.lang.String[] indentBlock(java.lang.String text)
This takes a large block of text, possibly containing multiple lines, splits it up, then attempts to indent of of the lines to make good looking code.

Parameters:
text - A String to break apart and indent.
Returns:
The resulting array of indented strings.

countLines

protected int countLines(java.lang.String text)
Count the number of lines in a given text block.

Parameters:
text - The text block to count.
Returns:
An int represnting the number of lines.

indentLine

protected java.lang.String indentLine(java.lang.String text,
                                      int level,
                                      int spacesPerLevel)
Take a single line of text and indent it to the proper lever for the code.

Parameters:
text - A String to indent.
level - An int representing the indent level.
spacesPerLevel - An int representing the number of spaces per indent level.
Returns:
The indented string.

indentLine

protected java.lang.String indentLine(java.lang.String text)
Take a single line of text and indent it to the proper lever for the code. This takes the current settings from the DocInfo object.

Parameters:
text - The String to indent.
Returns:
The indented string.

outmsg

protected void outmsg(java.lang.String text)
               throws java.lang.Exception
Output a string to the user. If the quit flag is set then output will be suppressed, otherwise it will be dumped to stdout.

Parameters:
text - The String to dump out.
Throws:
java.lang.Exception

writeOutput

protected void writeOutput(java.lang.String text)
                    throws java.lang.Exception
Write some text to the output file.

Parameters:
text - A String to dump to the output file.
Returns:
None
Throws:
java.lang.Exception

checkParent

protected boolean checkParent(org.w3c.dom.Node node,
                              java.lang.String name)
Check a tag to see if it has the right parent.

Parameters:
node - The Node of the tag that we are checking.
name - The name of the parent that is the right one.
Returns:
true if name is the parent of node

increaseIndent

protected void increaseIndent()
Increase the indent level of the output java code. This method is usually used in conjuction with the indentLine() method.


decreaseIndent

protected void decreaseIndent()
Decrease the indent level of the output java code. Usually used in conjuction with the indentLine() method.



Copyright ? 2006 Brigham Young University, Configurable Computing Laboratory. All Rights Reserved.