Package sc.parser

Class FormatContext

  • Direct Known Subclasses:
    LineFormatContext

    public class FormatContext
    extends java.lang.Object
    Handles spacing, indentation, and newlines for 'generated' parse nodes. When you parse a grammar, spacing is turned into literal string nodes. When you generate language elements, they turn into SpacingParseNode, and NewlineParseNode instances which initially do not have a string value. It makes sense to do this on a separate pass - after the tree is fully formed. This is the formatting phase and the FormatContext stores the state of the formatting process - where we are in the both the ParseNode and SemanticValue trees.
    • Field Detail

      • savedIndentLevels

        public IntStack savedIndentLevels
      • currentStartIndex

        public int currentStartIndex
    • Constructor Detail

      • FormatContext

        public FormatContext​(ParentParseNode curParent,
                             int curChildIndex,
                             int initIndent,
                             java.lang.Object lastNextValue,
                             java.lang.Object curSemVal)
    • Method Detail

      • setReplaceNode

        public void setReplaceNode​(IParseNode node)
      • createReplaceNode

        public IParseNode createReplaceNode()
      • append

        public void append​(java.lang.CharSequence seq)
      • appendNoStyle

        public void appendNoStyle​(java.lang.CharSequence seq)
      • appendWithStyle

        public void appendWithStyle​(java.lang.CharSequence seq)
      • setStyleBuffer

        public void setStyleBuffer​(java.lang.StringBuilder styleBuffer)
      • getResult

        public java.lang.CharSequence getResult()
      • prevChar

        public int prevChar()
      • nextChar

        public int nextChar()
      • nextSemanticValue

        public java.lang.Object nextSemanticValue()
      • nextSemanticNode

        public java.lang.Object nextSemanticNode()
      • prevSemanticValue

        public java.lang.Object prevSemanticValue()
      • prevSemanticValue

        public java.lang.Object prevSemanticValue​(int skip)
      • indent

        public void indent​(int ct)
      • indentWithStyle

        public void indentWithStyle​(int ct)
      • pushIndent

        public void pushIndent()
      • getCurrentIndent

        public int getCurrentIndent()
      • popIndent

        public int popIndent()
      • autoPopIndent

        public void autoPopIndent()
      • getNextSemanticNode

        public SemanticNode getNextSemanticNode()
        Returns the next enclosing type or tag for html
      • getPrevSemanticNode

        public SemanticNode getPrevSemanticNode()