MCPcopy Index your code
hub / github.com/endbasic/endbasic / split_display_message

Method split_display_message

core/src/compiler/mod.rs:155–171  ·  view source on GitHub ↗

Splits a textual error message into its source position and message. TODO(jmmv): This is a hack to support the current needs of std and allow migrating its code to this new implementation. Once migrated, revisit this.

(&self)

Source from the content-addressed store, hash-verified

153 /// TODO(jmmv): This is a hack to support the current needs of std and allow migrating its
154 /// code to this new implementation. Once migrated, revisit this.
155 fn split_display_message(&self) -> (LineCol, String) {
156 let display = self.to_string();
157 let mut parts = display.splitn(3, ':');
158 let line = parts
159 .next()
160 .expect("CompilerError display always has line")
161 .parse()
162 .expect("CompilerError line is always numeric");
163 let col = parts
164 .next()
165 .expect("CompilerError display always has column")
166 .parse()
167 .expect("CompilerError column is always numeric");
168 let message =
169 parts.next().expect("CompilerError display always has message").trim_start().to_owned();
170 (LineCol { line, col }, message)
171 }
172
173 /// Returns the source position where this compilation error happened.
174 pub fn pos(&self) -> LineCol {

Callers 2

posMethod · 0.80
message_without_posMethod · 0.80

Calls 2

parseMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected