{"record":{"id":"1688d29c9a499b83","repo":"dianping/cat","slug":"unexpected-token-value-at-line-line-col-co","errorCode":null,"errorMessage":"Unexpected token '{value}' at line {line}, col {col}.","messagePattern":"Unexpected token '(.+?)' at line (.+?), col (.+?)\\.","errorType":"exception","errorClass":"SyntaxError","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/editor/worker-css.js","lineNumber":3462,"sourceCode":"                    } else {\n                        throw ex;\n                    }\n                }\n\n            },\n            _readWhitespace: function(){\n\n                var tokenStream = this._tokenStream,\n                    ws = \"\";\n\n                while(tokenStream.match(Tokens.S)){\n                    ws += tokenStream.token().value;\n                }\n\n                return ws;\n            },\n            _unexpectedToken: function(token){\n                throw new SyntaxError(\"Unexpected token '\" + token.value + \"' at line \" + token.startLine + \", col \" + token.startCol + \".\", token.startLine, token.startCol);\n            },\n            _verifyEnd: function(){\n                if (this._tokenStream.LA(1) != Tokens.EOF){\n                    this._unexpectedToken(this._tokenStream.LT(1));\n                }\n            },\n            _validateProperty: function(property, value){\n                Validation.validate(property, value);\n            },\n\n            parse: function(input){\n                this._tokenStream = new TokenStream(input, Tokens);\n                this._stylesheet();\n            },\n\n            parseStyleSheet: function(input){\n                return this.parse(input);\n            },","sourceCodeStart":3444,"sourceCodeEnd":3480,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/editor/worker-css.js#L3444-L3480","documentation":"Thrown by the parser's `_unexpectedToken(token)` helper — its generic 'this token cannot appear here' signal. Its main caller is `_verifyEnd()`, which asserts that after a top-level construct is parsed only EOF remains; any trailing token (e.g. a stray `}` or `;` after the stylesheet's rules, or leftovers after skipping an unknown construct) triggers the throw with the offending token's value and position.","triggerScenarios":"Extra closing `}` at end of file so a rule's parse ends early and garbage remains; stray `;` or junk tokens after a completed rule that `_verifyEnd()` then sees; skipping an unknown @-rule leaves tokens the walker didn't consume; mismatched braces anywhere that make nesting bookkeeping end mid-file.","commonSituations":"Deleting a rule and leaving its closing brace; merge conflicts producing doubled `}}`; minified CSS with an off-by-one brace; hand-rolled CSS concatenation joining fragments without balancing braces.","solutions":["Go to the reported line/col — the token printed in the message is the exact character that shouldn't be there; delete it (usually a surplus `}` or `;`).","Run an brace/paren balance check over the file; an unmatched `{` earlier shifts everything and produces this error far from the cause.","Auto-format (Prettier/stylelint --fix) the file — formatters surface unbalanced blocks immediately.","In non-strict mode, read the fired 'error' events sequentially: the first one usually marks the true imbalance point."],"exampleFix":"/* before */\n.a { color: red; }\n}              /* Unexpected token '}' — surplus brace */\n\n/* after */\n.a { color: red; }","handlingStrategy":"try-catch","validationCode":"function balanced(css) {\n  var d = 0;\n  for (var i = 0; i < css.length; i++) {\n    if (css[i] === '{') d++;\n    else if (css[i] === '}') { if (--d < 0) return 'extra } at ' + i; }\n  }\n  return d ? 'missing } x' + d : null;\n}","typeGuard":null,"tryCatchPattern":"try {\n  parser.parse(css);\n} catch (ex) {\n  if (/Unexpected token/.test(ex.message) && ex.line) { jumpTo(ex.line, ex.col); return; }\n  throw ex;\n}","preventionTips":["Run a brace-balance pre-check on generated/merged CSS.","Use Prettier or stylelint --fix; both refuse unbalanced files and show where.","After deleting rules, verify the file with the editor's bracket-matching before saving.","Treat 'Unexpected token' positions as the tail symptom — search upward for the real imbalance."],"tags":["css","parser","syntax-error","unexpected-token","braces"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}