Package org.scijava.parse
Class Group
- java.lang.Object
-
- org.scijava.parse.Token
-
- org.scijava.parse.Operator
-
- org.scijava.parse.Group
-
- All Implemented Interfaces:
java.lang.Comparable<Operator>
public class Group extends Operator
A group is a special N-ary operator delineated by a left-hand symbol and a right-hand symbol, with comma-separated arguments.Typically, these are various forms of parentheses, although in principle any pair of two distinct symbols is allowed.
- Author:
- Curtis Rueden
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.scijava.parse.Operator
Operator.Associativity
-
-
Constructor Summary
Constructors Constructor Description Group(java.lang.String initiator, java.lang.String terminator, double precedence)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getArity()
1 for unary, 2 for binary, etc.java.lang.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.java.lang.String
toString()
-
Methods inherited from class org.scijava.parse.Operator
compareTo, getAssociativity, getPrecedence, isLeftAssociative, isPostfix, isRightAssociative
-
-
-
-
Method Detail
-
getTerminator
public java.lang.String getTerminator()
-
incArity
public void incArity()
-
matches
public 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.Note that this method intentionally does not compare arity; the idea is that if you have a
Group
and callinstance()
to duplicate it, that copy will match this one, even though the copy initially starts at arity 0.
-
getArity
public int getArity()
Description copied from class:Operator
1 for unary, 2 for binary, etc.
-
isInfix
public boolean isInfix()
Description copied from class:Operator
True iff the operator is an infix operator (e.g.,a-b
).
-
isPrefix
public boolean isPrefix()
Description copied from class:Operator
True iff the operator is a prefix operator (e.g.,-a
).
-
instance
public Group instance()
Creates an instance of a group operator, using this one as a template.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.
-
-