OptionalOrRequiredArgument : Type Ellipsis IDENTIFIER
429081
def p_OptionalOrRequiredArgument(p):
  """"""
  p[0] = model.OperationArgument(type=p[1], ellipsis=p[2], name=p[3])
908111
Rule InterfaceDeclaration() {
        return Sequence(
                INTERFACE,
                Identifier(),
                Optional(TypeParameters()),
                Optional(EXTENDS, ClassTypeList()),
                InterfaceBody()
        );
    }
923443
private TypeArgSignature parseTypeArg() {
		int ch = peekChar();
		switch (ch) {
		case '*':
			return new TypeArgSignature(
					(char) nextChar(TypeArgSignature.UNBOUNDED_WILDCARD), null);
		case '+':
			return new TypeArgSignature(
					(char) nextChar(TypeArgSignature.UPPERBOUND_WILDCARD),
					parseFieldTypeSignature());
		case '-':
			return new TypeArgSignature(
					(char) nextChar(TypeArgSignature.LOWERBOUND_WILDCARD),
					parseFieldTypeSignature());
		default:
			return new TypeArgSignature(TypeArgSignature.NO_WILDCARD,
					parseFieldTypeSignature());
		}
	}
1244845
function identifier(fnparam, prop) {
    var i = optionalidentifier(fnparam, prop);
    if (i) {
      return i;
    }
    if (state.tokens.curr.id === "function" && state.tokens.next.id === "(") {
      warning("W025");
    } else {
      error("E030", state.tokens.next, state.tokens.next.value);
    }
  }
575557
function argParser (arg, argName, strictType) {
  let parsedArg
  let argType = getItType(arg)
  const errFormatter = (errString, argType) => {
    return `${errString}\n|argName| = |${argName}|\n|type| = |${argType}|\n|arg| = |#{arg}|`
  }

  switch (argType) {
    case 'STRING':
      try {
        parsedArg = ['REGEXP', RegExp(arg)]
      } catch (e) {
        throw SyntaxError(errFormatter('cant compile this String to RegExp', argType))
      }
      break
    case 'REGEXP':
      parsedArg = ['REGEXP', arg]
      break
    case 'FUNCTION':
      parsedArg = ['FUNCTION', arg]
      break
    default:
      throw TypeError(errFormatter('argument must be String, RegExp or Function, but got', argType))
  }

  if (strictType && parsedArg[0] !== strictType.toUpperCase()) {
    throw TypeError(errFormatter(`argument must be ${strictType}, but got`, argType))
  }
  return parsedArg
}
1112645
function checkTypeParameter(node) {
            // Grammar Checking
            if (node.expression) {
                grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
            }
            checkSourceElement(node.constraint);
            getConstraintOfTypeParameter(getDeclaredTypeOfTypeParameter(getSymbolOfNode(node)));
            if (produceDiagnostics) {
                checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
            }
        }
905020
private Object prepareForDirectUsage(Class expectedClass, Object pArgument) {
        Class givenClass = pArgument.getClass();
        if (expectedClass.isArray() && List.class.isAssignableFrom(givenClass)) {
            return convertListToArray(expectedClass, (List) pArgument);
        } else {
        	return expectedClass.isAssignableFrom(givenClass) ? pArgument : null;
        }
    }
1276203
function getIdentifierForArgumentValue(value: ArgumentValue): mixed {
  switch (value.kind) {
    case 'Variable':
      return {variable: value.variableName};
    case 'Literal':
      return {value: value.value};
    case 'ListValue':
      return {
        list: value.items.map(item => getIdentifierForArgumentValue(item)),
      };
    case 'ObjectValue':
      return {
        object: value.fields.map(field => ({
          name: field.name,
          value: getIdentifierForArgumentValue(field.value),
        })),
      };
    default:
      invariant(
        false,
        'getIdentifierForArgumentValue(): Unsupported AST kind `%s`.',
        value.kind,
      );
  }
}
749970
private Optional<IRI> getPredicateIRI(DataRangeExpression expression) {
        if (expression instanceof Datatype) {
            return Optional.of(((Datatype) expression).getIRI());
        }
        if (expression instanceof DataPropertyRangeExpression) {
            return Optional.of(((DataPropertyRangeExpression) expression).getProperty().getIRI());
        }
        return Optional.empty();
    }
1351928
public final void typeArguments() throws RecognitionException {
		try {
			// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:143:5: ( LESS typeArgument ( COMMA typeArgument )* GREATER )
			// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:143:7: LESS typeArgument ( COMMA typeArgument )* GREATER
			{
			match(input,LESS,FOLLOW_LESS_in_typeArguments640); if (state.failed) return;
			pushFollow(FOLLOW_typeArgument_in_typeArguments642);
			typeArgument();
			state._fsp--;
			if (state.failed) return;
			// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:143:25: ( COMMA typeArgument )*
			loop12:
			while (true) {
				int alt12=2;
				int LA12_0 = input.LA(1);
				if ( (LA12_0==COMMA) ) {
					alt12=1;
				}

				switch (alt12) {
				case 1 :
					// src/main/resources/org/drools/compiler/lang/DRL6Expressions.g:143:26: COMMA typeArgument
					{
					match(input,COMMA,FOLLOW_COMMA_in_typeArguments645); if (state.failed) return;
					pushFollow(FOLLOW_typeArgument_in_typeArguments647);
					typeArgument();
					state._fsp--;
					if (state.failed) return;
					}
					break;

				default :
					break loop12;
				}
			}

			match(input,GREATER,FOLLOW_GREATER_in_typeArguments651); if (state.failed) return;
			}

		}

		catch (RecognitionException re) {
		    throw re;
		}

		finally {
			// do for sure before leaving
		}
	}
1157623
function invalidArgument(it, at, expected, actual) {
    throw new TypeError (
      it
      + ' expects its '
      + ordinal[at]
      + ' argument to '
      + expected
      + '\n  Actual: '
      + show (actual)
    );
  }
120483
private String typeParameters(Options opt, ParameterizedType t) {
	if (t == null)
	    return "";
	StringBuffer tp = new StringBuffer(1000).append("&lt;");
	Type args[] = t.typeArguments();
	for (int i = 0; i < args.length; i++) {
	    tp.append(type(opt, args[i], true));
	    if (i != args.length - 1)
		tp.append(", ");
	}
	return tp.append("&gt;").toString();
    }
499081
public final void typeArgument() throws RecognitionException {
		int typeArgument_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 54) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:557:5: ( type | '?' ( ( 'extends' | 'super' ) type )? )
			int alt76=2;
			int LA76_0 = input.LA(1);
			if ( (LA76_0==Identifier||LA76_0==65||LA76_0==67||LA76_0==71||LA76_0==77||LA76_0==85||LA76_0==92||LA76_0==94||LA76_0==105) ) {
				alt76=1;
			}
			else if ( (LA76_0==57) ) {
				alt76=2;
			}

			else {
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 76, 0, input);
				throw nvae;
			}

			switch (alt76) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:557:7: type
					{
					pushFollow(FOLLOW_type_in_typeArgument1963);
					type();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:558:7: '?' ( ( 'extends' | 'super' ) type )?
					{
					match(input,57,FOLLOW_57_in_typeArgument1971); if (state.failed) return;
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:558:11: ( ( 'extends' | 'super' ) type )?
					int alt75=2;
					int LA75_0 = input.LA(1);
					if ( (LA75_0==81||LA75_0==108) ) {
						alt75=1;
					}
					switch (alt75) {
						case 1 :
							// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:558:12: ( 'extends' | 'super' ) type
							{
							if ( input.LA(1)==81||input.LA(1)==108 ) {
								input.consume();
								state.errorRecovery=false;
								state.failed=false;
							}
							else {
								if (state.backtracking>0) {state.failed=true; return;}
								MismatchedSetException mse = new MismatchedSetException(null,input);
								throw mse;
							}
							pushFollow(FOLLOW_type_in_typeArgument1982);
							type();
							state._fsp--;
							if (state.failed) return;
							}
							break;

					}

					}
					break;

			}
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 54, typeArgument_StartIndex); }

		}
	}
1168336
protected Optional<TypeMirror> getFirstTypeArgument(TypeMirror type) {
        TypeMirror typeMirror = null;

        if (type instanceof DeclaredType) {
            DeclaredType declaredType = (DeclaredType) type;
            List<? extends TypeMirror> typeArguments = declaredType.getTypeArguments();
            if (CollectionUtils.isNotEmpty(typeArguments)) {
                typeMirror = typeArguments.get(0);
            }
        }
        return Optional.ofNullable(typeMirror);
    }
1132253
function validateArguments(parens, elements) {
            const leftParen = parens.leftParen;
            const tokenAfterLeftParen = sourceCode.getTokenAfter(leftParen);
            const hasLeftNewline = !astUtils.isTokenOnSameLine(leftParen, tokenAfterLeftParen);
            const needsNewlines = shouldHaveNewlines(elements, hasLeftNewline);

            for (let i = 0; i <= elements.length - 2; i++) {
                const currentElement = elements[i];
                const nextElement = elements[i + 1];
                const hasNewLine = currentElement.loc.end.line !== nextElement.loc.start.line;

                if (!hasNewLine && needsNewlines) {
                    context.report({
                        node: currentElement,
                        messageId: "expectedBetween",
                        fix: fixer => fixer.insertTextBefore(nextElement, "\n")
                    });
                }
            }
        }
138791
def _py_check_optional(parameter, tab, assign):
    
    if parameter.direction == "(out)":
        result = []
        checks = ["{0}_{1:d}.value==0".format(parameter.lname, i) for i in range(parameter.D)]
        spacing = len(tab) + 2 + 3 + 3 + 2
        result.append("{}if not all([{}]):".format(tab, present_params(checks, spacing, linecont=", ")))
        for line in assign:
            if assign is not None:
                result.append("{0}{1}".format(tab, line))
        result.append("{}else:".format(tab))
        result.append('{0}{0}result.add("{1}", None)'.format(tab, parameter.lname))
        return '\n'.join(result)
    else:
        return '\n'.join(assign)
269043
def _input_optional(inp):
        
        if 'default' in inp.keys():
            return True

        typ = inp.get('type')
        if isinstance(typ, six.string_types):
            return typ.endswith('?')
        elif isinstance(typ, dict):
            # TODO: handle case where iput type is dict
            return False
        elif isinstance(typ, list):
            # The cwltool validation expands optional arguments to
            # [u'null', <type>]
            return bool(u'null' in typ)
        else:
            raise ValueError('Invalid input "{}"'.format(inp.get['id']))