Class StackPrinter

java.lang.Object
eu.bandm.tools.d2d2.base.StackPrinter

public class StackPrinter extends Object
Prints the current stack state to a terminal, highlighting current position and possible continuations, for error diagnosis in interactive use cases.

ATTENTION: All methods in this context operate on the OBJECT IDENTITY of reference expressions, etc., thus identifying POSITIONS in complex expressions by object "==". This is only allowed in such a temporary "frozen" context.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    protected static class 
    Simply prints expressions, inserting parentheses by priority.
    protected static class 
    Single-use tool to find all sub-expressions of the current content model which are allowed to enter as next input in the current parsing situation.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected Reference
    Holds the last reference which has been entered and is stored in the next-lower State_singleton.
    (package private) Set<Expression>
    Holds all references the tags of which could be entered in the current parsing state.
    protected String
    Separator between the print-out of the name or symbol of a parser state and its highlighted content model.
    protected DiagnosisMarkUp
    Determines the optical appearance of current tag and possible subsequen tags.
    protected PrintWriter
    Target of the print-out.
    protected boolean
    Whether states will be printed which do not correspond to an element's content model but to an anonymous collection expression.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Default constructor: assumes a Vt100 terminal and output to std-err.
    protected
    Constructor with explicit selection of highlighting control.
    protected
    Constructor with explicit selection of highlighting control and output target.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    Worker method for printing one state of a parser state stack.
    protected String
    Delivers the name of the referred defintion to represent a reference expression.
    protected void
    print(String text, boolean active, boolean possible)
    Print a tag in the context of a parser state print-out.
    void
    Print one state of the parser state.
    void
    printStack(State state, boolean showIntermediate)
    Print one state of the parser state.
    protected String
    The printed identification of a parser frame.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • markup

      protected DiagnosisMarkUp markup
      Determines the optical appearance of current tag and possible subsequen tags.
    • printwriter

      protected PrintWriter printwriter
      Target of the print-out.
    • headerSeparatorString

      protected String headerSeparatorString
      Separator between the print-out of the name or symbol of a parser state and its highlighted content model.
    • showIntermediate

      protected boolean showIntermediate
      Whether states will be printed which do not correspond to an element's content model but to an anonymous collection expression.
    • activeRef

      protected Reference activeRef
      Holds the last reference which has been entered and is stored in the next-lower State_singleton. Causes highlighting.
    • followset

      Set<Expression> followset
      Holds all references the tags of which could be entered in the current parsing state. Causes highlighting. May contain tags/references and the special pseudo reference to pcdata.
  • Constructor Details

    • StackPrinter

      protected StackPrinter()
      Default constructor: assumes a Vt100 terminal and output to std-err.
    • StackPrinter

      protected StackPrinter(DiagnosisMarkUp markup)
      Constructor with explicit selection of highlighting control. Assumes output to std-err.
    • StackPrinter

      protected StackPrinter(DiagnosisMarkUp markup, PrintWriter pw)
      Constructor with explicit selection of highlighting control and output target.
  • Method Details

    • stateLabel

      protected String stateLabel(State s)
      The printed identification of a parser frame. Either the name of an elemente reference or a symbol for an intermediate collection expression.
    • print

      protected void print(String text, boolean active, boolean possible)
      Print a tag in the context of a parser state print-out.
      Parameters:
      text - to print
      active - whether the element is currently open in the parser state
      possible - whether the element is an allowed input in the parser state
    • printStack

      public void printStack(State state)
      Print one state of the parser state. The states are defined in Text2Udom. This method is a service access point and can be called from outside.
    • printStack

      public void printStack(State state, boolean showIntermediate)
      Print one state of the parser state. The states are defined in Text2Udom. This method is a service access point and can be called from outside.
      Parameters:
      showIntermediate - whether states will be printed which do not correspond to an element's content model but to an anonymous collection expression.
    • doPrintStack

      protected void doPrintStack(State state)
      Worker method for printing one state of a parser state stack.
    • getRefTag

      protected String getRefTag(Reference ref)
      Delivers the name of the referred defintion to represent a reference expression.