1. 解决 std::regex 解析失败问题

This commit is contained in:
xuhong 2024-09-14 17:36:38 +08:00
parent 970d339dc8
commit 173b277d42
1 changed files with 6 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import { MINode } from "./mi_parse";
const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-\>\ \<\:\(\)]*|\[\d+\])\s*=\s*/;
const variableRegex = /^[a-zA-Z_\-\'][a-zA-Z0-9_\-\>\ \\\']*/;
const resultRegex = /^([a-zA-Z_\-][a-zA-Z0-9_\-<> :(),]*|\[\d+\])\s*=\s*/;
const variableRegex = /^[a-zA-Z_\-\'\(][a-zA-Z0-9_\-\>\ \\\'\)\:]*/;
const errorRegex = /^\<.+?\>/;
const referenceStringRegex = /^(0x[0-9a-fA-F]+\s*)"/;
const referenceRegex = /^(0x[0-9a-fA-F]+)/;
@ -278,6 +278,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
const variableMatch = resultRegex.exec(value);
if (!variableMatch)
{
logger.debug(`parseResult: match fail, value:${JSON.stringify(value)}`);
return undefined;
}
value = value.substring(variableMatch[0].length).trim();
@ -288,7 +289,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
}
let tmpName = name.split(" ");
if(tmpName.length>1 && !name.includes("anonymous union")){
if(tmpName.length>1 && !name.includes("anonymous union") && !name.includes(',')){
name = tmpName[tmpName.length-1];
}
@ -296,6 +297,8 @@ export function expandValue(variableCreate: Function, value: string, root: strin
if (pushToStack){
stack.push(variable);
}
logger.debug(`parseResult: will parseValue, name:${name}, value:${JSON.stringify(value)}`);
const val = parseValue();
if (pushToStack){
stack.pop();