diff --git a/src/views/yeahmao/code_gen/codeGenJson.vue b/src/views/yeahmao/code_gen/codeGenJson.vue index 45a0facf7283e8cc1aafba8af444834ddb6d605f..7810d5bfcf6a8bd6e8b9175f8c558c6f7b656d80 100644 --- a/src/views/yeahmao/code_gen/codeGenJson.vue +++ b/src/views/yeahmao/code_gen/codeGenJson.vue @@ -98,7 +98,8 @@ export default { }, winError() { var objJson = []; - var r = /\/\/ (.*)\n\/\/\n#define (\S+)\s+(\d+)L/g; + // // (.*)\n//\n#define (\S+)\s+(\d+)L/g + var r = /\/\/ (.*)\n\/\/\n#define (\S+)\s+(\d+)L/g; var a = null; while ((a = r.exec(this.current.input))) { //循环执行匹配操作 console.log("匹配文本 = " + a[0] + " a.index = " + a.index + " r.lastIndex = " + r.lastIndex); //显示每次匹配后返回的数组信息 diff --git a/src/views/yeahmao/constFinder.vue b/src/views/yeahmao/constFinder.vue index a36e2eaf8fc0bf12783eb30289ff17d4146caffb..f5eda5b310a231a0efe9258ee19954006fcc2284 100644 --- a/src/views/yeahmao/constFinder.vue +++ b/src/views/yeahmao/constFinder.vue @@ -42,12 +42,26 @@ export default { item.hex = hex; this.kMaps[k] = item; this.kMaps[v] = item; - this.kMaps[hex] = item; }); }, methods: { handle() { - var item = this.kMaps[this.current.input]; + var input = this.current.input.trim(); + // 支持后缀H、h、L、l + if (input.endsWith('H') || input.endsWith('h')) { + input = '0x' + input.slice(0, -1); + } else if (input.endsWith('L') || input.endsWith('l')) { + input = input.slice(0, -1); + } + + var item = null; + // 不是数字 + if (isNaN(Number(input))) { + item = this.kMaps[input]; + } else { + // 转为数字,然后转为字符串 + item = this.kMaps[Number(input) + '']; + } console.log(item) if (item) { this.current.output = item;