Skip to content
Snippets Groups Projects
Commit 408dc7a2 authored by rdubner's avatar rdubner
Browse files

Eliminate the ')' that replaced empty strings; replace it with '""'. Build in...

Eliminate the ')' that replaced empty strings; replace it with '""'.  Build in _groupvalue= processing
parent 632d0c84
No related branches found
No related tags found
No related merge requests found
import { MINode } from "./mi_parse";
import { CodeLens } from "vscode";
const resultRegex = /^([0-9a-zA-Z_\-][a-zA-Z0-9_\-\/]*|\[\d+\])\s*=\s*/; // Dubner added \/ so that a COBOL A of B could be represented A/b
const variableRegex = /^[0-9a-zA-Z_\-][a-zA-Z0-9_\-\/]*/; // Dubner added \/ so that a COBOL A of B could be represented A/b
const resultRegex = /^([0-9a-zA-Z_\-][a-zA-Z0-9_\-\/]*|\[\d+\])\s*=\s*/; // Dubner added \/ so that a COBOL 'A of B 'could be represented 'A/b'
const variableRegex = /^[0-9a-zA-Z_\-][a-zA-Z0-9_\-\/]*/; // Dubner added \/ so that a COBOL 'A of B' could be represented 'A/b'
const errorRegex = /^\<.+?\>/;
const referenceStringRegex = /^(0x[0-9a-fA-F]+\s*)"/;
const referenceRegex = /^0x[0-9a-fA-F]+/;
......@@ -29,6 +30,20 @@ export function isExpandable(value: string): number {
else return 0;
}
function GetImmediateGroupValue(str:string) : string {
var retval:string = "";
const find_me:string = "{_groupvalue=\"";
var nfound:number = str.indexOf(find_me);
if( nfound == 0 ) {
nfound += find_me.length;
while( nfound < str.length && str[nfound] != '"' ) {
retval += str[nfound];
nfound += 1;
}
}
return retval;
};
export function expandValue(variableCreate: Function, value: string, root: string = "", extra: any = undefined): any {
const parseCString = () => {
value = value.trim();
......@@ -56,13 +71,16 @@ export function expandValue(variableCreate: Function, value: string, root: strin
};
const stack = [root];
const stack_of_groupvalues = [root];
let parseValue, parseCommaResult, parseCommaValue, parseResult, createValue;
let variable = "";
let recent_
const getNamespace = (variable) => {
let namespace = "";
let prefix = "";
stack.push(variable);
stack_of_groupvalues.push("");
stack.forEach(name => {
prefix = "";
if (name != "") {
......@@ -81,6 +99,7 @@ export function expandValue(variableCreate: Function, value: string, root: strin
}
});
stack.pop();
stack_of_groupvalues.pop();
return prefix + namespace;
};
......@@ -110,18 +129,23 @@ export function expandValue(variableCreate: Function, value: string, root: strin
if (newValPos != -1 && eqPos > newValPos || eqPos == -1) { // is value list
const values = [];
stack.push("[0]");
stack_of_groupvalues.push("");
let val = parseValue();
stack.pop();
stack_of_groupvalues.pop();
values.push(createValue("[0]", val));
const remaining = value;
let i = 0;
while (true) {
stack.push("[" + (++i) + "]");
stack_of_groupvalues.push("")
if (!(val = parseCommaValue())) {
stack.pop();
stack_of_groupvalues.pop();
break;
}
stack.pop();
stack_of_groupvalues.pop();
values.push(createValue("[" + i + "]", val));
}
value = value.substr(1).trim(); // }
......@@ -130,10 +154,19 @@ export function expandValue(variableCreate: Function, value: string, root: strin
let result = parseResult(true);
if (result) {
// Dubner added this _groupvalue hack. It is a pseudo-variable that
// doesn't appear in the locals list, but rather replaces the word
// 'Group' in a heirarchical variable listing. This code prevents
// it from appearing as a variable in the list
const results = [];
results.push(result);
while (result = parseCommaResult(true))
if(result["name"] != "_groupvalue"){
results.push(result);
}
while (result = parseCommaResult(true)){
if(result["name"] != "_groupvalue"){
results.push(result);
}
}
value = value.substr(1).trim(); // }
return results;
}
......@@ -201,19 +234,29 @@ export function expandValue(variableCreate: Function, value: string, root: strin
return undefined;
value = value.substr(variableMatch[0].length).trim();
const name = variable = variableMatch[1];
if (pushToStack)
if (pushToStack){
stack.push(variable);
var groupvalue:string = GetImmediateGroupValue(value);
stack_of_groupvalues.push(groupvalue);
}
const val = parseValue();
if (pushToStack)
if (pushToStack){
stack.pop();
return createValue(name, val);
}
var retval = createValue(name, val);
if (pushToStack){
stack_of_groupvalues.pop();
}
return retval
};
createValue = (name, val) => {
let ref = 0;
if (typeof val == "object") {
ref = variableCreate(val);
val = "Object";
//val = "Objecttt"; // This is the original code
val = stack_of_groupvalues[stack_of_groupvalues.length-1];
} else if (typeof val == "string" && val.startsWith("*0x")) {
if (extra && MINode.valueOf(extra, "arg") == "1") {
ref = variableCreate(getNamespace("*(" + name), { arg: true });
......
......@@ -417,7 +417,15 @@ export class MI2 extends EventEmitter implements IBackend {
}
retval += ch ;
}
//console.log("convert_mi_variables(2): ", retval); // DUBNERDEBUG
console.log("convert_mi_variables(2): ", retval); // DUBNERDEBUG
// var nfound = retval.indexOf('[');
// if(nfound != -1){
// var newr = retval.substr(0,nfound)
// newr = newr + "[{name=\"L01\",value=\"{_groupvalue=\\\"Snap!\\\",fullname=\\\"RobertDubner\\\",L02={_groupvalue=\\\"Crackle!\\\",firstname = \\\"Robert\\\", lastname = \\\"Dubner\\\",L03={_groupvalue=\\\"Pop!\\\",firstname = \\\"Judy\\\", lastname = \\\"Ruderman\\\"}}}\"}]\n";
// console.log("convert_mi_variables(3): ", newr); // DUBNERDEBUG
// retval = newr;
// }
}
}
......
......@@ -421,7 +421,12 @@ export class MI2DebugSession extends DebugSession {
}
} else {
if (variable.valueStr !== undefined) {
let expanded = expandValue(createVariable, `{${variable.name}=${variable.valueStr})`, "", variable.raw);
var vstr = variable.valueStr;
if(vstr == "") {
vstr = '""' ;
}
console.log("findOrCreateVariable(1)", vstr); //DUBNERDEBUG
let expanded = expandValue(createVariable, `{${variable.name}=${vstr}`, "", variable.raw);
if (expanded) {
if (typeof expanded[0] == "string")
expanded = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment