Class StringNode

All Implemented Interfaces:
MoveCheckable, TreeMember, ParseTree, SyntaxTree, TerminalNode, Tree
Direct Known Subclasses:
Directive

public class StringNode extends UnparsableASTNode
String node provides a terminal node with arbitrary contents. This is useful for inserting strings into the printed code such as comments. Only use this terminal node for non-parsed tokens like comments, whitespace or preprocessor directives. For all other syntax features, use the local roots system. Parse tree search doesn't work inside string nodes as they are not parsed.
See Also:
  • Constructor Details

    • StringNode

      public StringNode(String content)
      Creates a new string node with the given string content.
      Parameters:
      content - The string to create a token for
    • StringNode

      public StringNode(String content, boolean doNewlineInsertion)
      Creates a new string node with the given string content and a newline insertion flag.
      Parameters:
      content - The string to create a token for
      doNewlineInsertion - Whether to insert a newline before each group of unparsable AST nodes in the printer
  • Method Details

    • getPrinted

      protected String getPrinted()
      Description copied from class: ASTNode
      Generates the string representation of this AST object as it would be in the generated code.
      Specified by:
      getPrinted in class ASTNode
      Returns:
      The printed string for this AST object
    • doNewlineInsertion

      public boolean doNewlineInsertion()
      Description copied from class: UnparsableASTNode
      If true, the printer will insert a newline before each group of consecutive unparsable AST nodes.
      Overrides:
      doNewlineInsertion in class UnparsableASTNode
      Returns:
      If newline insertion should happen with this node
    • getContent

      protected String getContent()
      Returns the string node's content.
      Returns:
      The content