All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class parse.Unparser

java.lang.Object
   |
   +----parse.Unparser

public class Unparser
extends Object
Allows Parsable objects to output a description of themselves in a format such that the Parser can later read them in and recreate them. Every parsable object has an unparse() method.

This code is (c) 1996 Leemon Baird <leemon@cs.cmu.edu>, http://www.cs.cmu.edu/~baird
The source and object code may be redistributed freely. If the code is modified, please state so in the comments.

Version:
1.0, 10 March 96
Author:
Leemon Baird
See Also:
Parser

Variable Index

 o currCol
 o currIndent
 o indent
 o labels
 o labelUnparsed
 o maxIndent
 o maxLen
 o out

Constructor Index

 o Unparser(PrintStream, int, int, int, Hashtable)
Unparse with each indent being ind spaces, up to a maximum of max spaces.

Method Index

 o close()
Close the output file.
 o emit(boolean)
Output "true" or "false".
 o emit(char)
Output x.
 o emit(double)
Output x.
 o emit(float)
Output x.
 o emit(int)
Output x.
 o emit(long)
Output x.
 o emit(Object)
Output a string representing this object.
 o emit(String)
Output the string to whatever output is being unparsed to
 o emitLine()
End the current line and indent the next line appropriately.
 o emitLine(boolean)
Output x and start a new line.
 o emitLine(char)
Output x and start a new line.
 o emitLine(double)
Output x and start a new line.
 o emitLine(float)
Output x and start a new line.
 o emitLine(int)
Output x and start a new line.
 o emitLine(long)
Output x and start a new line.
 o emitLine(Object)
Output x and start a new line.
 o emitLine(String)
Output x and start a new line.
 o emitUnparse(Parsable, int)
unparse a class by calling its unparse method.
 o emitUnparseWithClassName(Parsable, int, boolean)
Output the class name of the object, then unparse it.
 o indent()
Cause all following emitLine() calls to indent the following line more.
 o indent(int)
Indent all future lines, and also emit n less than a normal indent right now.
 o unindent()
Cause all following emitLine() calls to indent the following line less.

Variables

 o indent
 protected int indent
 o currIndent
 protected int currIndent
 o maxIndent
 protected int maxIndent
 o maxLen
 protected int maxLen
 o out
 protected PrintStream out
 o currCol
 protected int currCol
 o labels
 protected Hashtable labels
 o labelUnparsed
 protected Hashtable labelUnparsed

Constructors

 o Unparser
 public Unparser(PrintStream s,
                 int ind,
                 int max,
                 int len,
                 Hashtable defUseLabels)
Unparse with each indent being ind spaces, up to a maximum of max spaces. If max=-1, then there is no limit on how far it can indent. Lines wrap after len columns. If len=-1, then lines do not automatically wrap. defUseLabels is the hash table created by the parser that tells about when #DEF and #USE were used.

Methods

 o emit
 public void emit(String x)
Output the string to whatever output is being unparsed to

 o emitLine
 public void emitLine()
End the current line and indent the next line appropriately.

 o close
 public void close()
Close the output file.

 o indent
 public void indent(int n)
Indent all future lines, and also emit n less than a normal indent right now.

 o indent
 public void indent()
Cause all following emitLine() calls to indent the following line more.

 o unindent
 public void unindent()
Cause all following emitLine() calls to indent the following line less.

 o emit
 public void emit(int x)
Output x.

 o emit
 public void emit(long x)
Output x.

 o emit
 public void emit(float x)
Output x.

 o emit
 public void emit(double x)
Output x.

 o emit
 public void emit(char x)
Output x.

 o emit
 public void emit(boolean x)
Output "true" or "false".

 o emit
 public void emit(Object x)
Output a string representing this object.

 o emitLine
 public void emitLine(int x)
Output x and start a new line.

 o emitLine
 public void emitLine(long x)
Output x and start a new line.

 o emitLine
 public void emitLine(float x)
Output x and start a new line.

 o emitLine
 public void emitLine(double x)
Output x and start a new line.

 o emitLine
 public void emitLine(char x)
Output x and start a new line.

 o emitLine
 public void emitLine(boolean x)
Output x and start a new line.

 o emitLine
 public void emitLine(String x)
Output x and start a new line.

 o emitLine
 public void emitLine(Object x)
Output x and start a new line.

 o emitUnparseWithClassName
 public void emitUnparseWithClassName(Parsable obj,
                                      int lang,
                                      boolean showPackage)
Output the class name of the object, then unparse it. If not showPackage, then don't output the package name prefix.

 o emitUnparse
 public void emitUnparse(Parsable obj,
                         int lang)
unparse a class by calling its unparse method. If the class was within a #DEF or #USE statement, emit that too.


All Packages  Class Hierarchy  This Package  Previous  Next  Index