Class Core.Pat

Direct Known Subclasses:
Core.Con0Pat, Core.ConPat, Core.ListPat, Core.LiteralPat, Core.NamedPat, Core.RecordPat, Core.TuplePat, Core.WildcardPat
Enclosing class:
Core

public abstract static class Core.Pat extends Core.BaseNode
Base class for a pattern.

For example, "x" in "val x = 5" is a Core.IdPat; the "(x, y) in "val (x, y) = makePair 1 2" is a Core.TuplePat.

  • Field Details

    • type

      public final Type type
  • Constructor Details

  • Method Details

    • type

      public Type type()
      Returns the type.
    • accept

      public abstract Core.Pat accept(Shuttle shuttle)
      Description copied from class: AstNode
      Accepts a shuttle, calling the Shuttle.visit(net.hydromatic.morel.ast.Ast.Literal) method appropriate to the type of this node, and returning the result.
      Overrides:
      accept in class Core.BaseNode
    • describe

      public String describe(Describer describer)
      Converts this pattern to a string.

      The result is similar to that of AstNode.toString(), except that identifiers are permuted. For example, if a pattern includes "c.3" and "c.2" but not "c.0" or "c.1", then "c.3" will be printed as "c" and "c.2" will be printed as "c.1".

      This behavior makes plans more concise if their local variables happen to have the same name as other variables that occur in functions in the session history.