flowbased / fbp

FBP flow definition language parser
114 stars 19 forks source link

JSON to FBP problem #89

Closed Dragomir-Ivanov closed 4 years ago

Dragomir-Ivanov commented 6 years ago

Trying to convert JSON to FBP, I get the following.

fbp out.json > somefile.fbp 
/usr/lib/node_modules/fbp/bin/fbp:25
  return console.log(parser.serialize(fs.readFileSync(file, 'utf-8')));
                            ^

TypeError: parser.serialize is not a function
    at Object.<anonymous> (/usr/lib/node_modules/fbp/bin/fbp:25:29)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:389:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:504:3
jonnor commented 6 years ago

@Dragomir-Ivanov what version of fbp package are you using?

Please paste output of npm list | grep fbp

Dragomir-Ivanov commented 6 years ago

@jonnor drago@T430s:~/SCE/cs-sce1/node_modules/the-graph/themes$ npm list | grep fbp ├── UNMET DEPENDENCY fbp-graph@^0.1.0 npm ERR! missing: @pleasetrythisathome/react.animate@0.0.4, required by the-graph@0.11.1 npm ERR! missing: create-react-class@^15.6.2, required by the-graph@0.11.1 npm ERR! missing: ease-component@^1.0.0, required by the-graph@0.11.1 npm ERR! missing: fbp-graph@^0.1.0, required by the-graph@0.11.1 npm ERR! missing: font-awesome@^4.6.3, required by the-graph@0.11.1 npm ERR! missing: hammerjs@^2.0.8, required by the-graph@0.11.1 npm ERR! missing: klayjs-noflo@^0.3.1, required by the-graph@0.11.1 npm ERR! missing: tv4@^1.3.0, required by the-graph@0.11.1

Mrinaldo commented 6 years ago

I got this error: `$ fbp graphs/ssiGeneration.json > graphs/ssiGeneration.fbp C:\Users\fmuser\AppData\Roaming\npm\node_modules\fbp\bin\fbp:25 return console.log(parser.serialize(fs.readFileSync(file, 'utf-8'))); ^

TypeError: parser.serialize is not a function at Object. (C:\Users\fmuser\AppData\Roaming\npm\node_modules\fbp\bin\fbp:25:29) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:191:16) at bootstrap_node.js:612:3 `

jonnor commented 6 years ago

@Mrinaldo and which version of fbp do you have?

LeuisKen commented 5 years ago

I got this error using the latest version 1.7.0, and you can figure out why this happen using the code:

var parser = require('fbp');

// Some FBP syntax code
var fbpData = "'hello, world!' -> IN Display(Output)";

console.log(Object.keys(parser));

// Parse into a Graph definition JSON object
var graphDefinition = parser.parse(fbpData, {caseSensitive: true});

console.log(Object.keys(parser));

and the console outputs:

image

It since that the parser.serialize method that using for parse json was added after parser.parse was called. That's why we got error using the command fbp, and this error not happened by using npm run test because tests defined in spec/fbp.coffee called the parser.parse before spec/json.coffee runs.

: )