public class Group extends Operator
Typically, these are various forms of parentheses, although in principle any pair of two distinct symbols is allowed.
Operator.Associativity
Constructor and Description |
---|
Group(String initiator,
String terminator,
double precedence) |
Modifier and Type | Method and Description |
---|---|
int |
getArity()
1 for unary, 2 for binary, etc.
|
String |
getTerminator() |
void |
incArity() |
Group |
instance()
Creates an instance of a group operator, using this one as a template.
|
boolean |
isInfix()
True iff the operator is an infix operator (e.g.,
a-b ). |
boolean |
isPrefix()
True iff the operator is a prefix operator (e.g.,
-a ). |
boolean |
matches(Group g)
Returns true iff the given group is the same as this one, in terms of token
(lefthand symbol), terminator (righthand symbol) and precedence.
|
String |
toString() |
compareTo, getAssociativity, getPrecedence, isLeftAssociative, isPostfix, isRightAssociative
public String getTerminator()
public void incArity()
public boolean matches(Group g)
Note that this method intentionally does not compare arity; the idea is
that if you have a Group
and call instance()
to duplicate
it, that copy will match this one, even though the copy initially starts at
arity 0.
public int getArity()
Operator
public boolean isInfix()
Operator
a-b
).public boolean isPrefix()
Operator
-a
).public Group instance()
The created group will have the same initiator and terminator symbols, as
well as the same precedence. But it will begin as a nullary group until
incArity()
is called.
Copyright © 2015–2022 SciJava. All rights reserved.