{"record":{"id":"421a40fd5341638c","repo":"rust-lang/rust-analyzer","slug":"unexpected-character","errorCode":null,"errorMessage":"unexpected character: `{}`","messagePattern":"unexpected character: `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/ungrammar/src/lexer.rs","lineNumber":114,"sourceCode":"            }\n            TokenKind::Token(buf)\n        }\n        c if is_ident_char(c) => {\n            let mut buf = String::new();\n            buf.push(c);\n            loop {\n                match chars.clone().next() {\n                    Some(c) if is_ident_char(c) => {\n                        chars.next();\n                        buf.push(c);\n                    }\n                    _ => break,\n                }\n            }\n            TokenKind::Node(buf)\n        }\n        '\\r' => bail!(\"unexpected `\\\\r`, only Unix-style line endings allowed\"),\n        c => bail!(\"unexpected character: `{}`\", c),\n    };\n\n    *input = chars.as_str();\n    Ok(res)\n}\n\nfn is_escapable(c: char) -> bool {\n    matches!(c, '\\\\' | '\\'')\n}\nfn is_whitespace(c: char) -> bool {\n    matches!(c, ' ' | '\\t' | '\\n')\n}\nfn is_ident_char(c: char) -> bool {\n    matches!(c, 'a'..='z' | 'A'..='Z' | '_')\n}\n","sourceCodeStart":96,"sourceCodeEnd":130,"githubUrl":"https://github.com/rust-lang/rust-analyzer/blob/e8f7e90aa3e7b26aa9a000200f606c1078da99ec/lib/ungrammar/src/lexer.rs#L96-L130","documentation":"Fallback lexer error in ungrammar's `advance`: any character that does not start a known token (identifier char, whitespace, punctuation like `= | ( ) * ? ;`, `'`, etc.) is rejected with this message naming the offending character.","triggerScenarios":"A `.ungrammar` file contains a character outside the grammar's alphabet, e.g. `\"` quotes, `#` comments, tabs in odd spots (if not treated as whitespace), unicode look-alikes, or stray operators.","commonSituations":"Copy-pasting grammar snippets from docs/websites (smart quotes, non-breaking spaces); inventing syntax unsupported by ungrammar; typos.","solutions":["Locate the reported character and replace or remove it","Replace smart quotes with plain `'` and non-breaking spaces with regular spaces","Consult ungrammar syntax docs to confirm the construct is supported (nodes, tokens, `=`, `|`, `*`, `?`, `(`, `)`, `;`)","Check for invisible unicode characters with a hex viewer if the character looks correct"],"exampleFix":"// before\nExpr = “literal”\n// after\nExpr = 'literal'","handlingStrategy":"validation","validationCode":"// spot suspicious characters before parsing\nfn has_suspect_chars(src: &str) -> Vec<char> {\n    src.chars().filter(|&c| {\n        matches!(c, '\\u{201c}' | '\\u{201d}' | '\\u{2018}' | '\\u{2019}' | '\\u{00a0}')\n    }).collect()\n}","typeGuard":null,"tryCatchPattern":"match ungrammar::Grammar::parse(src) {\n    Err(e) if e.to_string().starts_with(\"unexpected character\") => {\n        eprintln!(\"remove the unsupported character: {e}\")\n    }\n    r => r?,\n}","preventionTips":["Paste as plain text to avoid smart quotes and NBSPs","Restrict edits to documented ungrammar syntax","Hex-inspect characters that look right but fail to lex"],"tags":["lexer","ungrammar","syntax","parse-error"],"backgroundTag":"unexpected-character","analyzedSha":"e8f7e90aa3e7b26aa9a000200f606c1078da99ec","analyzedAt":"2026-09-03T21:08:06.959Z","contentChangedAt":"2026-09-03T21:08:06.959Z","schemaVersion":2},"datasetVersion":"2026-09-11T07:07:21.782Z"}