Class AbstractingCExpressionVisitor

java.lang.Object
org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<StringBuilder>
org.variantsync.diffdetective.feature.cpp.AbstractingCExpressionVisitor
All Implemented Interfaces:
org.antlr.v4.runtime.tree.ParseTreeVisitor<StringBuilder>

public class AbstractingCExpressionVisitor extends org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<StringBuilder>
Unparses the syntax tree into a string for use as a boolean abstraction. This visitor produces almost the same string as ParseTree.getText() i.e., the result is the string passed to the parser where all characters ignored by the parser are removed. Removed characters are mostly whitespace and comments, although the semantics of the strings are equivalent (e.g., spaces in strings literals are kept). The difference lies in some special cases:
  • We handle the parse rule Defined specialOperatorArgument? specially and return "defined(argument)" instead of "definedargument". This prevents clashes with macros called "definedargument" and makes the result consistent with the semantically equivalent rule Defined ('(' specialOperatorArgument ')').
Author:
Benjamin Moosherr
  • Constructor Details

    • AbstractingCExpressionVisitor

      public AbstractingCExpressionVisitor()
  • Method Details

    • visitTerminal

      public StringBuilder visitTerminal(org.antlr.v4.runtime.tree.TerminalNode node)
      Specified by:
      visitTerminal in interface org.antlr.v4.runtime.tree.ParseTreeVisitor<StringBuilder>
      Overrides:
      visitTerminal in class org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<StringBuilder>
    • defaultResult

      protected StringBuilder defaultResult()
      Overrides:
      defaultResult in class org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<StringBuilder>
    • aggregateResult

      protected StringBuilder aggregateResult(StringBuilder aggregate, StringBuilder nextResult)
      Overrides:
      aggregateResult in class org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<StringBuilder>
    • visitChildren

      public StringBuilder visitChildren(org.antlr.v4.runtime.tree.RuleNode node)
      Specified by:
      visitChildren in interface org.antlr.v4.runtime.tree.ParseTreeVisitor<StringBuilder>
      Overrides:
      visitChildren in class org.antlr.v4.runtime.tree.AbstractParseTreeVisitor<StringBuilder>
    • visitSpecialOperator

      public StringBuilder visitSpecialOperator(CExpressionParser.SpecialOperatorContext ctx)