{"record":{"id":"8ace598b56008874","repo":"egametang/ET","slug":"condition-token-error-at-this-index-c","errorCode":null,"errorMessage":"condition token error at {this.index}: {c}","messagePattern":"condition token error at (.+?): (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprLexer.cs","lineNumber":117,"sourceCode":"                    return;\n                case '(':\n                    this.tokens.Add(new ConditionToken(ConditionTokenType.LeftParen, \"(\", 0));\n                    ++this.index;\n                    return;\n                case ')':\n                    this.tokens.Add(new ConditionToken(ConditionTokenType.RightParen, \")\", 0));\n                    ++this.index;\n                    return;\n                case ':':\n                    this.tokens.Add(new ConditionToken(ConditionTokenType.Colon, \":\", 0));\n                    ++this.index;\n                    return;\n                case ',':\n                    this.tokens.Add(new ConditionToken(ConditionTokenType.Comma, \",\", 0));\n                    ++this.index;\n                    return;\n                default:\n                    throw new Exception($\"condition token error at {this.index}: {c}\");\n            }\n        }\n\n        private void AddIfNext(char next, ConditionTokenType matchType, ConditionTokenType singleType)\n        {\n            char c = this.expr[this.index];\n            if (this.index + 1 < this.expr.Length && this.expr[this.index + 1] == next)\n            {\n                this.tokens.Add(new ConditionToken(matchType, $\"{c}{next}\", 0));\n                this.index += 2;\n                return;\n            }\n\n            this.tokens.Add(new ConditionToken(singleType, c.ToString(), 0));\n            ++this.index;\n        }\n\n        private void ExpectNext(char next, ConditionTokenType tokenType)","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/egametang/ET/blob/5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f/Packages/cn.etetet.conditionexpr/Scripts/Model/Share/ConditionExprLexer.cs#L99-L135","documentation":"Thrown by ConditionExprLexer.ReadOperator in its default case when the current character is not one of the recognized operator/punctuation chars (>, <, =, !, &, |, (, ), :, ,). Any other glyph the lexer cannot tokenize aborts tokenization with the offending index and character.","triggerScenarios":"A condition expression contains an unsupported character such as @, #, $, %, ;, +, -, *, /, [, ], or a non-ASCII symbol. For example 'HP >= 50;' (trailing semicolon) or 'A & B' using a single ampersand where '&&' is required (single & is handled, but stray symbols are not).","commonSituations":"Copy-paste from a rich-text/Excel source that inserted special characters; a trailing semicolon or stray whitespace-like glyph; an attempt to use arithmetic (+, -, *, /) which the grammar does not support; a full-width (CJK) punctuation character.","solutions":["Remove or replace the unsupported character in the condition expression.","Check for full-width/CJK punctuation and replace with ASCII equivalents.","Remove trailing semicolons or stray symbols copied from documents.","Validate expression strings with the lexer at config-import time to surface the bad index/char early."],"exampleFix":"// before (expression cell)\n//   HP >= 50;\n// after\n//   HP >= 50","handlingStrategy":"validation","validationCode":"// At config import, tokenize every expression and surface lexer errors with index/char:\ntry { new ConditionExprLexer(expr).Tokenize(); }\ncatch (Exception e) { Log.Error($\"bad expr '{expr}': {e.Message}\"); }","typeGuard":"// Reject expressions containing characters outside the allowed set before runtime.\nstatic readonly HashSet<char> Allowed = new(\"><=!&|():,\");\nstatic bool HasOnlyAllowedChars(string expr, out int badIdx, out char badChar)","tryCatchPattern":null,"preventionTips":["Watch for full-width/CJK punctuation copied from documents.","Remove trailing semicolons and stray symbols.","Add a build-time lint pass over all condition cells."],"tags":["conditionexpr","lexer","parsing","invalid-character","config","csharp","unity"],"backgroundTag":null,"analyzedSha":"5cab01f7a8bee5f49f4781eebe9e2b1c6d7ebe0f","analyzedAt":"2026-08-13T21:10:40.377Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}