Class StackPrinter.ExpressionPrinter

Enclosing class:
StackPrinter

protected static class StackPrinter.ExpressionPrinter extends SinglePhase
Simply prints expressions, inserting parentheses by priority. The derived class (local to StackPrinter) does additional highlighting for all contained references.
  • Field Details

    • pw

      protected PrintWriter pw
      The target for printing
    • precedence

      protected int precedence
      Reigster for the current precedence, for inserting parentheses.
  • Constructor Details

    • ExpressionPrinter

      public ExpressionPrinter(PrintWriter pw)
      Only constructor.
  • Method Details

    • action

      public void action(Reference x)
      Print the source text of a reference.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Pcdata x)
      Print the symbolic tag for pcdata contents.
      Overrides:
      action in class SinglePhase
    • printPar

      protected void printPar(Expression x)
      Prints the the contents of a modifier Opt/Star/Plus. Alt, Perm and Seq are enclosed in brackets, with reset precedence, others not.
    • action

      public void action(Opt x)
      Overrides:
      action in class SinglePhase
    • action

      public void action(Star x)
      Overrides:
      action in class SinglePhase
    • action

      public void action(Plus x)
      Overrides:
      action in class SinglePhase
    • printMult

      protected void printMult(Collection<Expression> subs, String sep, int prec)
      Prints the argument sequence of Seq/Alt/Perm and puts parentheses iff the precedence decreases.
    • action

      public void action(Alt x)
      Print an alternative expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Seq x)
      Print a sequence expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Perm x)
      Print a permutation expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Insertion x)
      Print an insertion expression. Most insertions have been eliminated in ResolvedModule, but some (containing only one reference) are inserted to close cycles.
      Overrides:
      action in class SinglePhase
    • printCharBin

      void printCharBin(CharBinary x, String sep, int predec)
      Print a binary character operator.
    • action

      public void action(CharJoin x)
      Print a character join expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharCut x)
      Print a character cut expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharMinus x)
      Print a character minus expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharRange x)
      Print a character range expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(ParseParticle x)
      Print a parse particle sub-expression of a character expression.
      Overrides:
      action in class SinglePhase
    • action

      public void action(CharSetConst x)
      Print a character set constant.
      Overrides:
      action in class SinglePhase
    • action

      public void action(StringConst x)
      Print a string constant.
      Overrides:
      action in class SinglePhase
    • action

      public void action(Subst x)
      Raise error because all substitutions must be resolved when a parsing state is constructed.
      Overrides:
      action in class SinglePhase