Class ToIr

java.lang.Object
org.clafer.frontend.ToIr

public final class ToIr extends Object
The explicit IR of a model in the full syntax, as the compiler gives it (clafer -m clafer), and its scopes. The clafers are the Symbols: their UIDs, supers, references, cards, group cards, modifiers and initializers, with the layout, the braces and the defaults gone. The constraints, objectives, assertions, initial values and transitions are resolved by the Resolver, and the scopes are the compiler's (ScopeAnalysis). As in the compiler, the constraints of a reference to a set expression come first in its clafer, a nested assertion is quantified over the instances of its clafer (all this_ : A.b |), and the objectives and assertions are collected in pre-order.

Every rich explicit model is such a model, so it gives its own IR back.

  • Method Details

    • toIr

      public static ToIr.Result toIr(String source)
      Parses a model in one file, without reading its imports, finds its symbols, and builds its explicit IR.
      Parameters:
      source - the text of a model
      Returns:
      its IR and the errors
    • read

      public static ToIr.Result read(String path)
      Reads a model and its imports, and builds its explicit IR.
      Parameters:
      path - the model's file
    • toIr

      public static ToIr.Result toIr(ModelFiles files)
      Builds the explicit IR of the files of a model: their concatenation, with their options combined.
    • toIr

      public static ToIr.Result toIr(Syntax.Model model, Symbols.Result symbols, Ir.Options options)
      Parameters:
      model - a parsed model without errors
      symbols - its symbols, without errors
      options - the options of the explicit model
      Returns:
      its IR and the errors of this pass
    • toIr

      public static ToIr.Result toIr(Syntax.Model model, Symbols.Result symbols, Ir.Options options, Optional<Integer> decimalDigits)
      Parameters:
      decimalDigits - the decimal scale of --decimal-digits, if given