Package org.scijava.parsington
Class Group
java.lang.Object
org.scijava.parsington.Token
org.scijava.parsington.Operator
org.scijava.parsington.Group
- All Implemented Interfaces:
Comparable<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.parsington.Operator
Operator.Associativity
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getArity()
Gets the operator's arity.Gets the group's terminator symbol.void
incArity()
Increments the group's arity.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
Gets whether the given group is the same as this one, in terms of token (lefthand symbol), terminator (righthand symbol) and precedence.toString()
Methods inherited from class org.scijava.parsington.Operator
compareTo, getAssociativity, getPrecedence, isLeftAssociative, isPostfix, isRightAssociative
-
Constructor Details
-
Group
Creates a new group.- Parameters:
initiator
- The lefthand symbol signaling the start of the group.terminator
- The righthand symbol signaling the end of the group.precedence
- The group's operator precedence.
-
-
Method Details
-
getTerminator
Gets the group's terminator symbol. (UseToken.getToken()
to obtain the initiator symbol.)- Returns:
- The terminator symbol.
-
incArity
public void incArity()Increments the group's arity. -
matches
Gets whether 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.- Parameters:
g
- The group to compare with this one.- Returns:
- True iff the given group is the same as this one, in terms of token, terminator, and precedence.
-
getArity
public int getArity()Description copied from class:Operator
Gets the operator's arity. -
isInfix
public boolean isInfix()Description copied from class:Operator
Gets whether the operator is an infix operator (e.g.,a-b
). -
isPrefix
public boolean isPrefix()Description copied from class:Operator
Gets whether the operator is a prefix operator (e.g.,-a
). -
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. -
toString
-