Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function parseCode(code){
let Blockly = window.Blockly;
let workspace = Blockly.mainWorkspace;
let ast1, xml1;
let options;
let comments = [];
let block_loc = [];
try{
//console1.value = '';
window._BIDE.b2c_error = false
options = {
sourceType: 'module',
locations: true,
onComment: comments
};
ast1 = acorn.parse(code, options);
console.log(comments)
xml1 = walk1(ast1, comments, block_loc);
//console.log(xml1);
workspace.clear();
Blockly.Xml.domToWorkspace(workspace, xml1);
workspace.cleanUp_(); // workspace.cleanUp(); // In updated Blockly
window._BIDE.updateWorkspace()
//workspace.addChangeListener(window._BIDE.updateWorkspace);
//var blockly_code = Blockly.JavaScript.workspaceToCode(Blockly.mainWorkspace);
//console.log(blockly_code);
} catch(err){
console.log(err)
window._BIDE.b2c_error = true
let tb = workspace.topBlocks_
let id = tb[tb.length-1].id