gate.yam.translate
Class Cursor

java.lang.Object
  extended by gate.yam.translate.Cursor

public class Cursor
extends Object

Helper class for pretty-printer. Represents a position in a tree traversal, and provides manipulation of spacing at that position.

Author:
Hamish Cunningham

Field Summary
 NodeKind previousKind
          Previous position type.
 
Constructor Summary
Cursor(SimpleNode rootNode, int leadingMin, int leadingMax)
          Construction from parse tree root node.
 
Method Summary
 void advance()
          Advance to the next Unit or Word sequence.
 boolean atEnd()
          Finished the document?
 void blanksAfter(int min, int max)
          Set the number of blank lines following this position.
 void blanksAfter(int norm, int min, int max)
          Set the number of blank lines following this position.
 void blanksAfter(Token gapStart, Token gapEnd, int norm, int min, int max)
          Set the number of blank lines in a token sequence.
 NodeKind findNodeKind(SimpleNode n)
          Type of the next node after the current Sep sequence.
 SimpleNode getHereNode()
          First node in current position.
 NodeKind getKind()
          Position type.
 NodeKind getNextKind()
          Next position type.
 SimpleNode getNextNode()
          Next node from current position.
 NodeKind getPreviousKind()
          Previous position type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

previousKind

public NodeKind previousKind
Previous position type.

Constructor Detail

Cursor

public Cursor(SimpleNode rootNode,
              int leadingMin,
              int leadingMax)
Construction from parse tree root node.

Method Detail

advance

public void advance()
Advance to the next Unit or Word sequence. (Ignores top-level anchors.)


findNodeKind

public NodeKind findNodeKind(SimpleNode n)
Type of the next node after the current Sep sequence.


getHereNode

public SimpleNode getHereNode()
First node in current position.


getKind

public NodeKind getKind()
Position type.


getPreviousKind

public NodeKind getPreviousKind()
Previous position type.


getNextNode

public SimpleNode getNextNode()
Next node from current position.


getNextKind

public NodeKind getNextKind()
Next position type.


atEnd

public boolean atEnd()
Finished the document?


blanksAfter

public void blanksAfter(int min,
                        int max)
Set the number of blank lines following this position.


blanksAfter

public void blanksAfter(int norm,
                        int min,
                        int max)
Set the number of blank lines following this position.


blanksAfter

public void blanksAfter(Token gapStart,
                        Token gapEnd,
                        int norm,
                        int min,
                        int max)
Set the number of blank lines in a token sequence. Tokens gapStart and gapEnd must not be null.