|
1 | 1 | import { VariableObject } from "./backend";
|
2 | 2 | import { MINode } from "./mi_parse";
|
3 | 3 |
|
4 |
| -const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-]*|\[\d+\])\s*=\s*/; |
5 |
| -const variableRegex = /^[a-zA-Z_\-][a-zA-Z0-9_\-]*/; |
| 4 | +const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-<> :(),]*|\[\d+\])\s*=\s*/; |
| 5 | +const variableRegex = /^[a-zA-Z_\-\'\(][a-zA-Z0-9_\-\>\ \\\'\)\:]*/; |
6 | 6 | const errorRegex = /^\<.+?\>/;
|
7 | 7 | const referenceStringRegex = /^(0x[0-9a-fA-F]+\s*)"/;
|
8 | 8 | const referenceRegex = /^0x[0-9a-fA-F]+/;
|
@@ -105,14 +105,18 @@ export function expandValue(variableCreate: (arg: VariableObject | string, optio
|
105 | 105 | const eqPos = value.indexOf("=");
|
106 | 106 | const newValPos1 = value.indexOf("{");
|
107 | 107 | const newValPos2 = value.indexOf(",");
|
| 108 | + const newValPos3 = value.indexOf("}"); |
108 | 109 | let newValPos = newValPos1;
|
109 | 110 | if (newValPos2 != -1 && newValPos2 < newValPos1)
|
110 | 111 | newValPos = newValPos2;
|
111 |
| - if (newValPos != -1 && eqPos > newValPos || eqPos == -1) { // is value list |
| 112 | + if (newValPos != -1 && eqPos > newValPos || eqPos == -1 || eqPos > newValPos3 || value.startsWith("std::")) { // is value list |
112 | 113 | const values = [];
|
113 | 114 | stack.push("[0]");
|
114 | 115 | let val = parseValue();
|
115 | 116 | stack.pop();
|
| 117 | + if(typeof val == "string" && val.endsWith('>')){ |
| 118 | + val = val.substring(0, val.length - 2); |
| 119 | + } |
116 | 120 | values.push(createValue("[0]", val));
|
117 | 121 | const remaining = value;
|
118 | 122 | let i = 0;
|
@@ -191,18 +195,30 @@ export function expandValue(variableCreate: (arg: VariableObject | string, optio
|
191 | 195 | return parseCString();
|
192 | 196 | else if (value[0] == '{')
|
193 | 197 | return parseTupleOrList();
|
| 198 | + else if(value.startsWith("std::")){ |
| 199 | + const eqPos = value.indexOf("="); |
| 200 | + value = value.substring(eqPos + 2); |
| 201 | + return parseValue(); |
| 202 | + } |
194 | 203 | else
|
195 | 204 | return parsePrimitive();
|
196 | 205 | };
|
197 | 206 |
|
198 | 207 | parseResult = (pushToStack: boolean = false) => {
|
| 208 | + if (value[0] == '<') { |
| 209 | + value = value.substring(1).trim(); |
| 210 | + } |
199 | 211 | value = value.trim();
|
200 | 212 | value = value.replace(/^static /, "");
|
201 | 213 | const variableMatch = resultRegex.exec(value);
|
202 | 214 | if (!variableMatch)
|
203 | 215 | return undefined;
|
204 | 216 | value = value.substring(variableMatch[0].length).trim();
|
205 |
| - const name = variable = variableMatch[1]; |
| 217 | + let name = variable = variableMatch[1].trim(); |
| 218 | + const tmpName = name.split(" "); |
| 219 | + if(tmpName.length > 1 && !name.includes("anonymous union") && !name.includes(',')){ |
| 220 | + name = tmpName[tmpName.length - 1]; |
| 221 | + } |
206 | 222 | if (pushToStack)
|
207 | 223 | stack.push(variable);
|
208 | 224 | const val = parseValue();
|
@@ -231,6 +247,15 @@ export function expandValue(variableCreate: (arg: VariableObject | string, optio
|
231 | 247 | ref = variableCreate(getNamespace(name));
|
232 | 248 | val = "...";
|
233 | 249 | }
|
| 250 | + value = value.trim(); |
| 251 | + if (value[0] == ','){ |
| 252 | + let tmp = value; |
| 253 | + tmp = tmp.substring(1).trim(); |
| 254 | + if(tmp.startsWith("<No data fields>")){ |
| 255 | + value = tmp = tmp.substring("<No data fields>".length); |
| 256 | + } |
| 257 | + } |
| 258 | + |
234 | 259 | return {
|
235 | 260 | name: name,
|
236 | 261 | value: val,
|
|
0 commit comments