{"record":{"id":"acb37c70a0bbd3a1","repo":"dianping/cat","slug":"expected-name-at-line-line-col-col","errorCode":null,"errorMessage":"Expected {name} at line {line}, col {col}.","messagePattern":"Expected (.+?) at line (.+?), col (.+?)\\.","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-css.js","lineNumber":1591,"sourceCode":"\n        while(i < len){\n            if (tt == tokenTypes[i++]){\n                return true;\n            }\n        }\n        this.unget();\n        return false;\n    },\n    mustMatch: function(tokenTypes, channel){\n\n        var token;\n        if (!(tokenTypes instanceof Array)){\n            tokenTypes = [tokenTypes];\n        }\n\n        if (!this.match.apply(this, arguments)){\n            token = this.LT(1);\n            throw new SyntaxError(\"Expected \" + this._tokenData[tokenTypes[0]].name +\n                \" at line \" + token.startLine + \", col \" + token.startCol + \".\", token.startLine, token.startCol);\n        }\n    },\n    advance: function(tokenTypes, channel){\n\n        while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){\n            this.get();\n        }\n\n        return this.LA(0);\n    },\n    get: function(channel){\n\n        var tokenInfo   = this._tokenData,\n            reader      = this._reader,\n            value,\n            i           =0,\n            len         = tokenInfo.length,","sourceCodeStart":1573,"sourceCodeEnd":1609,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-css.js#L1573-L1609","documentation":"Thrown by the CSS worker's `TokenStream.mustMatch(tokenTypes)` when the next token(s) do not match a token type the grammar requires (selector colon, semicolon, closing brace, etc.). `mustMatch` is the parser's assertion operator: after the failed match it reads the actual lookahead token (`LT(1)`) and throws a `SyntaxError` naming the expected token type and the actual token's position. It means the statement was structurally incomplete or malformed at that point.","triggerScenarios":"CSS missing a mandatory token: a declaration without a semicolon before `}` (`a{color:red}`), a media query missing `{`, `@import` without a following string/URL token, a selector missing its block. Any call like `tokenStream.mustMatch(Tokens.SEMICOLON)` / `mustMatch(Tokens.RBRACE)` / `mustMatch(Tokens.COLON)` where the input has something else (or EOF) next.","commonSituations":"Hand-typing CSS and forgetting `;` or `{}`; minifiers with bugs that drop trailing semicolons inside the wrong block; template literals that interpolate `undefined` leaving a hole where a token was expected; nested preprocessor output with an unclosed block.","solutions":["Go to the line/col in the message and add the token named as 'Expected {name}' (e.g. insert the missing `;`, `:`, `{`, `}` or `)`).","Look backwards from the reported position — the real mistake is usually an unterminated earlier rule (missing `}` or `;`) that shifted the parser onto the wrong token.","Run the stylesheet through CSSLint/stylelint to get all mustMatch failures at once instead of fixing one per parse.","If the CSS is machine-generated, fix the generator rather than patching output."],"exampleFix":"/* before */\n.menu { color: red }\n.footer { color: blue; } /* mustMatch(RBRACE/SEMICOLON) may fire on malformed earlier rules */\n\n/* after */\n.menu { color: red; }\n.footer { color: blue; }","handlingStrategy":"try-catch","validationCode":"function quickSanity(css) {\n  var depth = 0;\n  for (var i = 0; i < css.length; i++) {\n    if (css[i] === '{') depth++;\n    if (css[i] === '}') depth--;\n    if (depth < 0) return 'unexpected } at index ' + i;\n  }\n  return depth === 0 ? null : 'missing ' + depth + ' closing brace(s)';\n}","typeGuard":null,"tryCatchPattern":"try {\n  parser.parse(css);\n} catch (ex) {\n  if (ex.line && ex.col) { jumpTo(ex.line, ex.col, ex.message); return; } // SyntaxError carries position\n  throw ex;\n}","preventionTips":["Brace-balance check before parsing machine-produced CSS.","Use an editor with live CSS linting so missing tokens surface while typing.","Fix the FIRST reported error then re-parse — later positions are usually collateral.","Keep the parser in non-strict mode and render 'error' events inline instead of letting one throw abort everything."],"tags":["css","parser","syntax-error","tokens","validation"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}