{"record":{"id":"f7a875a907278f7a","repo":"babalae/better-genshin-impact","slug":"c","errorCode":null,"errorMessage":"无法识别的字符：'{c}'","messagePattern":"无法识别的字符：'(.+?)'","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"BetterGenshinImpact/GameTask/AutoFight/Script/ConditionEvaluator.cs","lineNumber":224,"sourceCode":"                // 多段动作名（如 芙芙-e-开场）只需其完整名称已声明即可整体并入，中间段无需单独声明；\n                // 没有任何已知前缀时 `-` 保持为独立减号运算符（如 t-5、since(1)-3）\n                if (i < expr.Length && expr[i] == '-')\n                {\n                    var candidateEnd = i + 1;\n                    while (candidateEnd < expr.Length && (char.IsLetterOrDigit(expr[candidateEnd]) || expr[candidateEnd] == '-'))\n                        candidateEnd++;\n                    while (candidateEnd > i && !knownIdentifiers.Contains(expr[start..candidateEnd]))\n                        candidateEnd--;\n                    if (candidateEnd > i) i = candidateEnd;\n                }\n                var word = expr[start..i];\n                tokens.Add(word is \"true\" or \"false\"\n                    ? new Token(TokenType.Bool, word)\n                    : new Token(TokenType.Identifier, word));\n                continue;\n            }\n\n            throw new InvalidOperationException($\"无法识别的字符：'{c}'\");\n        }\n\n        tokens.Add(new Token(TokenType.End, \"\"));\n        return tokens;\n    }\n\n    // ========== 语法分析（递归下降） ==========\n\n    private abstract class AstNode { }\n\n    private class BoolNode(bool value) : AstNode { public bool Value { get; } = value; }\n\n    private class NumberNode(double value) : AstNode { public double Value { get; } = value; }\n\n    private class FuncCallNode(string name, List<AstNode> args) : AstNode\n    {\n        public string Name { get; } = name;\n        public List<AstNode> Args { get; } = args;","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/babalae/better-genshin-impact/blob/a7cb36712dcb409be610257d877fcea3597e9d6b/BetterGenshinImpact/GameTask/AutoFight/Script/ConditionEvaluator.cs#L206-L242","documentation":"Thrown by ConditionEvaluator.Tokenize when the lexer encounters a character that is not whitespace, a recognized operator (&&, ||, !, +, -, *, /, >, <, =), parenthesis, comma, digit, or letter. The tokenizer has no rule for the character and aborts. Note: when called via Evaluate(), this exception is caught internally (line 147-151) and Evaluate returns false instead of propagating. When called via IsValidActionName(), it is also caught and returns false.","triggerScenarios":"A condition expression string contains an unsupported character such as '@', '#', '%', '^', '&', '~', '[', ']', '{', '}', or any non-ASCII symbol that is not a recognized CJK letter. For example: `q-ready() & low-hp@` or `count[3] > 2`.","commonSituations":"User writes a JSON strategy condition expression with a typo using square brackets, '@', or other symbols not in the supported grammar. Could also occur from copy-paste of programming syntax (array indexing, ternary operators) into the condition DSL.","solutions":["Inspect the condition expression for non-grammar characters (the exception message quotes the offending character).","Replace unsupported syntax: use '(' ')' for grouping instead of '[' ']', use '&&' '||' instead of other boolean operators.","Refer to supported operators: ||, &&, !, (), +, -, *, /, >, <, =, and function calls.","Validate the expression with ConditionEvaluator.IsValidActionName or a dry-run Evaluate before committing."],"exampleFix":"// before (unsupported square brackets)\n\"condition\": \"count[3] > 2\"\n\n// after (use function call syntax)\n\"condition\": \"count(3) > 2\"","handlingStrategy":"try-catch","validationCode":"// Validate a condition expression for unsupported characters before use\nstatic bool HasValidChars(string expr)\n{\n    var allowed = \"()&&!+-*/<>=,. \";\n    foreach (var c in expr)\n    {\n        if (char.IsLetterOrDigit(c) || allowed.Contains(c)) continue;\n        return false;\n    }\n    return true;\n}\n\nif (!HasValidChars(conditionExpr))\n    throw new ArgumentException($\"条件表达式含不支持的字符: {conditionExpr}\");","typeGuard":null,"tryCatchPattern":"// Evaluate already catches InvalidOperationException internally and returns false.\n// For direct Tokenize use (rare), wrap in try-catch:\ntry\n{\n    var tokens = Tokenize(expr, knownIdentifiers);\n}\ncatch (InvalidOperationException e) when (e.Message.Contains(\"无法识别的字符\"))\n{\n    Logger.LogWarning(\"条件表达式包含不支持的字符: {Msg}\", e.Message);\n    return false;\n}","preventionTips":["The Evaluate method already handles this gracefully — it catches the exception and returns false.","When writing condition expressions, use only: letters, digits, &&, ||, !, (), +-*/, <>=, commas, and function names.","Do not use square brackets, @, #, %, ^, ~, or other symbols — they are not in the grammar.","Test condition expressions in a dry-run Evaluate call with logging before deploying."],"tags":["condition-evaluator","lexer","expression","parser"],"backgroundTag":null,"analyzedSha":"a7cb36712dcb409be610257d877fcea3597e9d6b","analyzedAt":"2026-08-13T16:44:57.548Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}