Ejemplo n.º 1
0
/*-
 *-----------------------------------------------------------------------
 * CondToken --
 *	Return the next token from the input.
 *
 * Results:
 *	A Token for the next lexical token in the stream.
 *
 * Side Effects:
 *	condPushback will be set back to None if it is used.
 *-----------------------------------------------------------------------
 */
static Token
CondToken(bool doEval)
{

	if (condPushBack != None) {
		Token t;

		t = condPushBack;
		condPushBack = None;
		return t;
	}

	while (isspace(*condExpr))
		condExpr++;
	switch (*condExpr) {
	case '(':
		condExpr++;
		return LParen;
	case ')':
		condExpr++;
		return RParen;
	case '|':
		if (condExpr[1] == '|')
			condExpr++;
		condExpr++;
		return Or;
	case '&':
		if (condExpr[1] == '&')
			condExpr++;
		condExpr++;
		return And;
	case '!':
		condExpr++;
		return Not;
	case '\n':
	case '\0':
		return EndOfFile;
	case '"':
		return CondHandleString(doEval);
	case '$':
		return CondHandleVarSpec(doEval);
	case '0': case '1': case '2': case '3': case '4':
	case '5': case '6': case '7': case '8': case '9':
		return CondHandleNumber(doEval);
	default:
		return CondHandleDefault(doEval);
	}
}
Ejemplo n.º 2
0
/*-
 *-----------------------------------------------------------------------
 * CondToken --
 *	Return the next token from the input.
 *
 * Results:
 *	A Token for the next lexical token in the stream.
 *
 * Side Effects:
 *	condPushback will be set back to None if it is used.
 *-----------------------------------------------------------------------
 */
static Token
CondToken(bool doEval)
{

	if (condPushBack != None) {
		Token t;

		t = condPushBack;
		condPushBack = None;
		return t;
	}

	while (*condExpr == ' ' || *condExpr == '\t')
		condExpr++;
	switch (*condExpr) {
	case '(':
		condExpr++;
		return LParen;
	case ')':
		condExpr++;
		return RParen;
	case '|':
		if (condExpr[1] == '|')
			condExpr++;
		condExpr++;
		return Or;
	case '&':
		if (condExpr[1] == '&')
			condExpr++;
		condExpr++;
		return And;
	case '!':
		condExpr++;
		return Not;
	case '\n':
	case '\0':
		return EndOfFile;
	case '"':
		return CondHandleString(doEval);
	case '$':
		return CondHandleVarSpec(doEval);
	default:
		return CondHandleDefault(doEval);
	}
}