Skip to content

Commit

Permalink
new format of scope/vars
Browse files Browse the repository at this point in the history
  • Loading branch information
drom committed Mar 12, 2023
1 parent 7db9145 commit 07ef76c
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions lib/waveql-parser-with.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';

const get = require('lodash.get');
const get = require('./get-sig.js');

const diz = (cols, wires, path, rowIdx) => {
const diz = (cols, wires, path, rowIdx, labelo) => {
if (cols[0] !== 'DIZ') {
return;
}
Expand All @@ -11,12 +11,13 @@ const diz = (cols, wires, path, rowIdx) => {
const arg1 = cols[1]; // pipeline stages

// find all potential candidates
const othero0 = Object.keys(levelo).reduce((res, name) => {
const m = name.match(arg1);
// const othero0 = Object.keys(levelo).reduce((res, name) => {
const othero0 = levelo.body.reduce((res, ero) => {
const m = ero.name.match(arg1);
if (m) {
const {id, pc, go} = m.groups;
const stage = res[id] = (res[id] || {});
const desc = {name, ref: levelo[name]};
const desc = {name: ero.name, ref: ero.link};
if (pc) {
stage[pc] = desc;
} else
Expand All @@ -37,8 +38,7 @@ const diz = (cols, wires, path, rowIdx) => {
}
return res;
}, {});

return {kind: 'DIZ', idx: rowIdx, othero, clock: {name: 'clock', ref: levelo.clock}};
return {kind: 'DIZ', idx: rowIdx, othero, clock: {name: 'clock', ref: labelo.clock.ref}};
};

const waveqlParserWith = wires => str => {
Expand All @@ -55,7 +55,7 @@ const waveqlParserWith = wires => str => {

if (row[0] === '(') {
const cols = row.slice(1).split(/\s+/);
const res = diz(cols, wires, path, rowIdx); // || other commands
const res = diz(cols, wires, path, rowIdx, labelo); // || other commands
if (res) {
nRow = res;
return res;
Expand Down Expand Up @@ -103,6 +103,7 @@ const waveqlParserWith = wires => str => {
if (col === '/') { path.length = 0; return; }

mat = col.match(/^:(\S+)$/); if (mat) {
// console.log(JSON.stringify(labelo), rowo, mat[1]);
labelo[mat[1]] = rowo;
return;
}
Expand Down Expand Up @@ -139,14 +140,16 @@ const waveqlParserWith = wires => str => {
}

const newPath = path.concat(col);
const ref = get(wires, newPath, false);

if (typeof ref === 'string') {
rowo.name = col;
rowo.ref = ref;
} else
if (typeof ref === 'object') {
path.push(col);
const ero = get(wires, newPath, false);

if (ero) {
if (ero.kind === 'scope') {
path.push(col);
} else
if (ero.kind === 'var') {
rowo.name = col;
rowo.ref = ero.link;
}
}
});
return rowo;
Expand Down

0 comments on commit 07ef76c

Please sign in to comment.