Class FromBuilder

java.lang.Object
net.hydromatic.morel.ast.FromBuilder

public class FromBuilder extends Object
Builds a Core.From.

Simplifies the following patterns:

  • Converts "from v in list" to "list" (only works in buildSimplify(), not build());
  • Removes "where true" steps;
  • Removes empty "order" steps;
  • Removes trivial yield, e.g. "from v in list where condition yield v" becomes "from v in list where condition";
  • Inlines from expressions, e.g. "from v in (from w in list)" becomes "from w in list yield {v = w}".
  • Field Details

    • typeSystem

      private final TypeSystem typeSystem
    • env

      private final @Nullable Environment env
    • steps

      private final List<Core.FromStep> steps
    • bindings

      private final List<Binding> bindings
    • atom

      private boolean atom
    • removeIfNotLastIndex

      private int removeIfNotLastIndex
      If non-negative, flags that particular step should be removed if it is not the last step. (For example, "yield {i = i}", which changes the result shape if the last step but is otherwise a no-op.)
    • removeIfLastIndex

      private int removeIfLastIndex
      If non-negative, flags that particular step should be removed if it is the last step. (For example, we flatten "from p in (from q in list)", to "from q in list yield {p = q}" but we want to remove "yield {p = q}" if it turns out to be the last step.)
  • Constructor Details

  • Method Details