MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / format_syntax_error

Function format_syntax_error

src/parser/error_format.rs:58–80  ·  view source on GitHub ↗
(error: &SyntaxError)

Source from the content-addressed store, hash-verified

56}
57
58fn format_syntax_error(error: &SyntaxError) -> String {
59 match error {
60 SyntaxError::UnexpectedToken(_, byte, _) => {
61 let ch = *byte as char;
62 if ch.is_ascii_graphic() {
63 format!("Syntax error: unexpected character `{ch}`")
64 } else {
65 format!("Syntax error: unexpected byte 0x{byte:02X}")
66 }
67 }
68 SyntaxError::UnrecognizedToken(_, byte, _) => {
69 let ch = *byte as char;
70 if ch.is_ascii_graphic() {
71 format!("Syntax error: unrecognized character `{ch}`")
72 } else {
73 format!("Syntax error: unrecognized byte 0x{byte:02X}")
74 }
75 }
76 SyntaxError::UnexpectedEndOfFile(_, _) => {
77 "Syntax error: unexpected end of file".to_string()
78 }
79 }
80}
81
82/// Build a human-friendly comma-separated list of expected tokens.
83///

Callers 1

format_parse_errorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected