MCPcopy Create free account
hub / github.com/Marus/cortex-debug / parseMI

Function parseMI

src/backend/mi_parse.ts:157–356  ·  view source on GitHub ↗
(output: string)

Source from the content-addressed store, hash-verified

155const asyncClassRegex = /^(.*?),/;
156
157export function parseMI(output: string): MINode {
158 /*
159 output ==>
160 (
161 exec-async-output = [ token ] "*" ("stopped" | others) ( "," variable "=" (const | tuple | list) )* \n
162 status-async-output = [ token ] "+" ("stopped" | others) ( "," variable "=" (const | tuple | list) )* \n
163 notify-async-output = [ token ] "=" ("stopped" | others) ( "," variable "=" (const | tuple | list) )* \n
164 console-stream-output = "~" c-string \n
165 target-stream-output = "@" c-string \n
166 log-stream-output = "&" c-string \n
167 )*
168 [
169 [ token ] "^" ("done" | "running" | "connected" | "error" | "exit") ( "," variable "=" (const | tuple | list) )* \n
170 ]
171 "(gdb)" \n
172 */
173
174 let token;
175 const outOfBandRecord = [];
176 let resultRecords;
177
178 const asyncRecordType = {
179 '*': 'exec',
180 '+': 'status',
181 '=': 'notify'
182 };
183 const streamRecordType = {
184 '~': 'console',
185 '@': 'target',
186 '&': 'log'
187 };
188
189 const parseCString = () => {
190 if (output[0] !== '"') {
191 return '';
192 }
193 let stringEnd = 1;
194 let inString = true;
195 let remaining = output.substr(1);
196 let escaped = false;
197 while (inString) {
198 if (escaped) {
199 escaped = false;
200 }
201 else if (remaining[0] === '\\') {
202 escaped = true;
203 }
204 else if (remaining[0] === '"') {
205 inString = false;
206 }
207
208 remaining = remaining.substr(1);
209 stringEnd++;
210 }
211 let str;
212 try {
213 str = parseString(output.substr(0, stringEnd));
214 }

Callers 2

mi_parse.test.tsFile · 0.90
onOutputMethod · 0.90

Calls 2

parseCStringFunction · 0.70
parseTupleOrListFunction · 0.70

Tested by

no test coverage detected