{"record":{"id":"78ccd3e369472e14","repo":"oracle/graal","slug":"out-of-tokens","errorCode":null,"errorMessage":"Out of tokens","messagePattern":"Out of tokens","errorType":"validation","errorClass":"RuleParseError","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/core/match/processor/MatchProcessor.java","lineNumber":145,"sourceCode":"            }\n            tokens = list.toArray(new String[0]);\n\n            matchDescriptor = parseExpression();\n            if (!done()) {\n                throw new RuleParseError(\"didn't consume all tokens\");\n            }\n            capturedNames.add(0, \"root\");\n            capturedTypes.add(0, matchDescriptor.nodeType);\n        }\n\n        String next() {\n            return tokens[current++];\n        }\n\n        String peek(String name) {\n            if (current >= tokens.length) {\n                if (name == null) {\n                    throw new RuleParseError(\"Out of tokens\");\n                }\n                throw new RuleParseError(\"Out of tokens looking for %s\", name);\n            }\n            return tokens[current];\n        }\n\n        boolean done() {\n            return current == tokens.length;\n        }\n\n        private MatchDescriptor parseExpression() {\n            if (peek(\"(\").equals(\"(\")) {\n                next();\n                MatchDescriptor descriptor = parseType(true);\n                for (int n = 0; n < descriptor.nodeType.inputs.size(); n++) {\n                    if (peek(\"(\").equals(\"(\")) {\n                        descriptor.inputs[n] = parseExpression();\n                    } else {","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.processor/src/jdk/graal/compiler/core/match/processor/MatchProcessor.java#L127-L163","documentation":"Thrown by RuleParser.peek(null) when the parser needs the next token but the token array is exhausted. It is the generic out-of-input error: the rule string ended in the middle of a construct (unclosed parenthesis, missing node type after '=', trailing operator), and peek() was called without a descriptive name so no 'looking for' context is included.","triggerScenarios":"A truncated @MatchRule such as \"Add(\" or \"Add(x=\" — any rule where the tokenizer produces fewer tokens than the grammar requires. peek(null) is also called from the 'Extra tokens following match pattern' path, which is unreachable in practice when tokens are exhausted.","commonSituations":"Strings chopped by line-length reformatting; incomplete edits; accidentally terminating the annotation string early with a stray quote.","solutions":["Complete the pattern: balance parentheses and ensure every node type and captured name is present.","Format the rule on one line while editing to avoid truncation by formatters.","If the message lacks context, rebuild the rule incrementally from a minimal working example, adding one input at a time."],"exampleFix":"// before\n@MatchRule(\"Add(\")\n\n// after\n@MatchRule(\"Add(x, y)\")","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Compile-time error only. In tooling, surface javac diagnostics containing 'Out of tokens' together with the enclosing @MatchRule annotation for quick fixes.","preventionTips":["Complete all parentheses and name bindings before building.","Avoid line-wrapping or truncating rule strings with formatters.","Grow complex rules incrementally from a minimal working pattern."],"tags":["graalvm","match-rules","annotation-processing","compile-time"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}