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)
Creates a new group.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getArity()
Gets the operator's arity.
|
String |
getTerminator()
Gets the group's terminator symbol.
|
void |
incArity()
Increments the group's arity.
|
Group |
instance()
Creates an instance of a group operator, using this one as a template.
|
boolean |
isInfix()
Gets whether the operator is an infix operator (e.g.,
a-b). |
boolean |
isPrefix()
Gets whether the operator is a prefix operator (e.g.,
-a). |
boolean |
matches(Group g)
Gets whether 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, isRightAssociativepublic String getTerminator()
Token.getToken() to obtain the
initiator symbol.)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.
g - The group to compare with this one.public int getArity()
Operatorpublic boolean isInfix()
Operatora-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–2021 SciJava. All rights reserved.