- public TokenTuple increaseArity() {
- if( isNewSummary ) {
- return (TokenTuple) Canonical.makeCanonical(
- new TokenTuple(token, isNewSummary, ARITY_MANY)
- );
+ public TokenTuple unionArity( TokenTuple tt ) {
+ assert tt != null;
+ assert token == tt.token;
+ assert isMultiObject == tt.isMultiObject;
+
+ if( isMultiObject ) {
+ // for multiple objects only zero-or-mores combined are still zero-or-more
+ // when two tokens are present (absence of a token is arity=zero and is
+ // handled outside of this method)
+ if( arity == ARITY_ZEROORMORE && tt.arity == ARITY_ZEROORMORE ) {
+ return new TokenTuple( token, true, ARITY_ZEROORMORE ).makeCanonical();
+ } else {
+ return new TokenTuple( token, true, ARITY_ONEORMORE ).makeCanonical();
+ }
+
+ } else {
+ // a single object region's token can only have ZEROORMORE or ONE
+ if( arity == ARITY_ZEROORMORE && tt.arity == ARITY_ZEROORMORE ) {
+ return new TokenTuple( token, false, ARITY_ZEROORMORE ).makeCanonical();
+ } else {
+ return new TokenTuple( token, false, ARITY_ONE ).makeCanonical();
+ }