|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object orc.ast.extended.pattern.Pattern
public abstract class Pattern
Base interface for the abstract syntax of patterns. Patterns exist only in the extended abstract syntax. They desugar into a series of operations which terminate in variable bindings.
Field Summary | |
---|---|
protected static Argument |
EQUAL
|
static Argument |
ERROR
|
protected static Argument |
IF
|
protected static Argument |
NONE
|
protected static Argument |
SOME
|
protected static Argument |
TRYCONS
|
protected static Argument |
TRYNIL
|
static Argument |
TRYNONE
|
static Argument |
TRYSOME
|
Constructor Summary | |
---|---|
Pattern()
|
Method Summary | |
---|---|
static Expression |
caseof(Variable arg,
Variable s,
Expression succ,
Expression fail)
Constructs an optional case statement. |
static Expression |
compare(Argument s,
Argument t)
Construct an expression comparing two arguments. |
static Pattern |
condense(java.util.List<Pattern> ps)
Condense a sequence of patterns into a single pattern using the following strategy: An empty sequence of patterns becomes a wildcard pattern _. |
static Expression |
fail()
Return a default expression to use in case a pattern match fails. |
SourceLocation |
getSourceLocation()
|
static Expression |
lift(Variable x)
Lifts a partial function to a total function, using the ; combinator to detect a refusal to respond, and publishing optional values instead of values. |
static Expression |
nth(Argument s,
int i)
Construct an expression which publishes the ith element of tuple s. |
PatternSimplifier |
process(Variable fragment)
A different entry point for process, taking only a source variable. |
abstract void |
process(Variable fragment,
PatternSimplifier visitor)
Visit a pattern recursively, creating two products: An expression that will examine a value to determine whether it matches a pattern, building an output tuple of all value fragments which will be bound to variables. |
void |
setSourceLocation(SourceLocation location)
|
boolean |
strict()
|
static Expression |
trycons(Argument s)
Constructs an expression which will try to deconstruct an argument as if it were a list. |
static Expression |
trynil(Argument s)
Constructs an expression which tests whether the argument s can be treated as an empty list (nil). |
static Expression |
trysize(Argument s,
int n)
Construct an expression to determine whether the argument s may be viewed as a tuple of size n. |
static Expression |
unapply(Argument m,
Argument s)
Construct an expression which tries to find the inverse of the site m, and apply it to s. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface orc.ast.extended.ASTNode |
---|
accept |
Field Detail |
---|
protected static Argument IF
protected static Argument EQUAL
protected static Argument SOME
protected static Argument NONE
public static Argument ERROR
public static Argument TRYSOME
public static Argument TRYNONE
protected static Argument TRYCONS
protected static Argument TRYNIL
Constructor Detail |
---|
public Pattern()
Method Detail |
---|
public boolean strict()
public abstract void process(Variable fragment, PatternSimplifier visitor) throws PatternException
fragment
- A variable holding the current fragment of the value to be matchedvisitor
- A visitor object which accumulates an expression and a transformer
PatternException
public PatternSimplifier process(Variable fragment) throws PatternException
PatternException
public static Pattern condense(java.util.List<Pattern> ps)
ps
-
public static Expression compare(Argument s, Argument t)
s
- An argument to comparet
- An argument to compare
public static Expression nth(Argument s, int i)
s
- An argument bound to a tuplei
- An index into a tuple (starting at 0)
public static Expression trycons(Argument s)
s
- public static Expression trynil(Argument s)
s
- public static Expression trysize(Argument s, int n)
s
- Argument to testn
- Target aritypublic static Expression unapply(Argument m, Argument s)
m
- The site to unapplys
- Argument to the inversionPattern()
public static Expression lift(Variable x)
some(x) ; none
x
- public static Expression caseof(Variable arg, Variable s, Expression succ, Expression fail)
case arg of
some(s) -> succ
| none -> fail
arg
- s
- succ
- fail
- public static Expression fail()
public void setSourceLocation(SourceLocation location)
setSourceLocation
in interface Locatable
public SourceLocation getSourceLocation()
getSourceLocation
in interface ASTNode
getSourceLocation
in interface Located
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |