Class CodecTools

java.lang.Object
de.saar.chorus.domgraph.codec.CodecTools

public class CodecTools extends Object
Methods that are useful in the implementation of codecs.
Author:
Alexander Koller
  • Constructor Details

    • CodecTools

      public CodecTools()
  • Method Details

    • atomify

      public static String atomify(String label)
      Computes a string that is a valid Oz or Prolog atom from the argument. If the argument starts with a lowercase letter and all later symbols are letters, digit, or underscore, the argument itself is returned; otherwise, the argument is surrounded by quotes '...'.
      Parameters:
      label - a string
      Returns:
      the string possibly surrounded with quotes
    • varify

      public static String varify(String label)
      Computes a string that is a valid Prolog variable from the argument. If the argument starts with an uppercase letter or an underscore, it is returned directly; otherwise, it is prefixed with an underscore.

      Note that the returned string will still not be a valid Prolog variable name if it contains symbols that are not valid in Prolog variable names.

      Parameters:
      label - a String
      Returns:
      the string, possibly prefixed with an underscore
    • graphLabelsConsistencyAssertion

      public static void graphLabelsConsistencyAssertion(DomGraph graph, NodeLabels labels)
      Asserts that all labelled nodes in the dominance graph actually have labels. If this is not the case and assertions are enabled, then an assertion exception is thrown. This is useful in debugging codecs.
      Parameters:
      graph - a dominance graph
      labels - a matching labels object
    • removeTopEmptyFragment

      public static void removeTopEmptyFragment(DomGraph graph, int errorcode) throws MalformedDomgraphException
      Throws:
      MalformedDomgraphException