{"record":{"id":"9692db22d34f568c","repo":"egametang/ET","slug":"condition-token-expected-type-actual-token-t","errorCode":null,"errorMessage":"condition token expected: {type}, actual: {token.Text}","messagePattern":"condition token expected: (.+?), actual: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs","lineNumber":361,"sourceCode":"        }\n\n        private bool Match(ConditionTokenType type)\n        {\n            if (this.Current.Type != type)\n            {\n                return false;\n            }\n\n            ++this.position;\n            return true;\n        }\n\n        private ConditionToken Expect(ConditionTokenType type)\n        {\n            ConditionToken token = this.Current;\n            if (token.Type != type)\n            {\n                throw new Exception($\"condition token expected: {type}, actual: {token.Text}\");\n            }\n\n            ++this.position;\n            return token;\n        }\n\n        private ConditionToken Current => this.tokens[this.position];\n    }\n}\n","sourceCodeStart":343,"sourceCodeEnd":371,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprParser.cs#L343-L371","documentation":"Generic parser mismatch raised by Expect(): the current token's type does not equal the type the grammar requires at this position. This is the single guard behind every required-token step (RightParen, Number, Identifier, End), so most malformed-expression errors surface here.","triggerScenarios":"Missing comparison operator (`HP 0`), missing operand after an operator (`HP >`), unbalanced parentheses (`(HP > 0`), missing closing token / trailing garbage (`HP > 0 MP > 1` without a boolean operator), or a stray token where End was expected.","commonSituations":"Hand-editing a condition cell in Excel/Luban and dropping a character; copy-paste that loses the operator; locale/format issues where a comma vs period breaks tokenization upstream.","solutions":["Inspect the reported `expected` vs `actual` token: the actual token tells you what the lexer saw where the expected one should be.","Re-add the missing token (operator, operand, or closing paren) at that position.","If actual is an unexpected identifier after a complete expression, you probably forgot a `&&` / `||` between two sub-expressions.","Validate cells with the parser in a unit test or pre-commit lint so authoring errors are caught before export."],"exampleFix":"// before\nHP > 0 MP < 100\n// after\nHP > 0 && MP < 100","handlingStrategy":"try-catch","validationCode":"// cheap structural pre-check before full parse\nbool LooksBalanced(string expr)\n{\n    int depth = 0;\n    foreach (char c in expr)\n    {\n        if (c == '(') depth++;\n        else if (c == ')') { depth--; if (depth < 0) return false; }\n    }\n    return depth == 0;\n}","typeGuard":null,"tryCatchPattern":"try { ConditionRoot root = parser.Parse(); }\ncatch (Exception ex) when (ex.Message.StartsWith(\"condition token expected\"))\n{\n    // surface a friendly authoring error with the cell/row id\n    logger.Error($\"condition expression malformed: {ex.Message} in cell '{cell}'\");\n}","preventionTips":["Validate condition cells in a unit test or pre-export lint.","Always read the expected-vs-actual token in the message to locate the missing character.","When chaining sub-expressions, never forget the boolean operator between them."],"tags":["csharp","unity","conditionexpr","parser","config-data"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}