egametang/ET · error · Exception

condition compare op expected, actual: {token.Text}

Error message

condition compare op expected, actual: {token.Text}

What it means

Thrown by ConditionExprParser.ReadCompareOp as the default arm when the token following a variable (and optional params) is not a comparison operator. The grammar requires one of >, >=, <, <=, ==, != after the variable. Any other token (a bare number, identifier, end-of-input, etc.) is rejected.

Source

Thrown at Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs:232

            }

            this.Expect(ConditionTokenType.RightParen);
            return paramValues.ToArray();
        }

        private ConditionCompareOp ReadCompareOp()
        {
            ConditionToken token = this.Current;
            ++this.position;
            return token.Type switch
            {
                ConditionTokenType.Greater => ConditionCompareOp.Greater,
                ConditionTokenType.GreaterEqual => ConditionCompareOp.GreaterEqual,
                ConditionTokenType.Less => ConditionCompareOp.Less,
                ConditionTokenType.LessEqual => ConditionCompareOp.LessEqual,
                ConditionTokenType.Equal => ConditionCompareOp.Equal,
                ConditionTokenType.NotEqual => ConditionCompareOp.NotEqual,
                _ => throw new Exception($"condition compare op expected, actual: {token.Text}")
            };
        }

        private int ReadErrorCode()
        {
            ConditionToken token = this.Expect(ConditionTokenType.Number);
            if (token.Number < int.MinValue || token.Number > int.MaxValue)
            {
                throw new Exception($"condition error code out of range: {token.Number}");
            }

            return (int)token.Number;
        }

        private void ApplyErrorCode(BTNode node, int errorCode)
        {
            if (node is BTNumericCompare numericCompare)
            {

View on GitHub (pinned to 5cab01f7a8)

Solutions

  1. Ensure every comparison clause is 'Variable OP Number', e.g. 'HP > 50'.
  2. Use only the supported operators: >, >=, <, <=, ==, !=.
  3. Check the expression is complete (variable, operator, number all present).
  4. Validate expression strings at config-import time to flag missing operators.

Example fix

// before (expression cell)
//   HP 50
// after
//   HP > 50
Defensive patterns

Strategy: validation

Validate before calling

// Validate structure at import: each compare clause must be Variable (params?) Op Number.
// Ensure the token after the variable is one of >, >=, <, <=, ==, !=.

Type guard

static bool IsCompareToken(ConditionTokenType t) =>
    t is ConditionTokenType.Greater or ConditionTokenType.GreaterEqual or
           ConditionTokenType.Less or ConditionTokenType.LessEqual or
           ConditionTokenType.Equal or ConditionTokenType.NotEqual;

Prevention

When it happens

Trigger: An expression like 'HP 50' (missing operator), 'HP + 50' (unsupported '+'), 'HP & MP > 0' (misplaced logical op), or 'HP' at end of input with no operator and operand.

Common situations: Missing comparison operator typo; using arithmetic symbols the grammar lacks; malformed expression where an operand was omitted; copy-paste dropping the operator.

Related errors


AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13). Data as JSON: /api/errors/ed07f7d91d8fcf9e. Report an issue: GitHub.