Git Product home page Git Product logo

fbp's Introduction

FBP flow definition language parser

The fbp library provides a parser for a domain-specific language for flow-based-programming (FBP), used for defining graphs for FBP programming environments like NoFlo, MicroFlo and MsgFlo.

Usage

You can use the FBP parser in your JavaScript code with the following:

var parser = require('fbp');

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

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

When caseSensitive is false the parser will convert port names to lowercase. This is currently the default behavior, but in future releases the default will change to preserve case. It is therefore recommended that you always specify the caseSensitive option to make your code future-proof.

Command-line

The fbp package also provides a command-line tool for converting FBP files into JSON:

$ fbp somefile.fbp [--case-sensitive] > somefile.json

And for converting JSON files into FBP:

$ fbp somefile.json [--case-sensitive] > somefile.fbp

Language for Flow-Based Programming

FBP is a Domain-Specific Language (DSL) for easy graph definition. The syntax is the following:

  • 'somedata' -> PORT Process(Component) sends initial data somedata to port PORT of process Process that runs component Component
  • A(Component1) X -> Y B(Component2) sets up a connection between port X of process A that runs component Component1 and port Y of process B that runs component Component2

You can connect multiple components and ports together on one line, and separate connection definitions with a newline or a comma (,).

Components only have to be specified the first time you mention a new process. Afterwards, simply use the process name.

Example:

'somefile.txt' -> SOURCE Read(ReadFile) OUT -> IN Split(SplitStr)
Split OUT -> IN Count(Counter) COUNT -> IN Display(Output)
Read ERROR -> IN Display

The syntax also supports blank lines and comments. Comments start with the # character.

Example with the same graph than above :

# Read the content of "somefile.txt" and split it by line
'somefile.txt' -> SOURCE Read(ReadFile) OUT -> IN Split(SplitStr)

# Count the lines and display the result
Split() OUT -> IN Count(Counter) COUNT -> IN Display(Output)

# The read errors are also displayed
Read() ERROR -> IN Display()

Exporting ports

When FBP-defined graphs are used as subgraphs in other flows, it is often desirable to give more user-friendly names to their available ports. In the FBP language this is done by INPORT and OUTPORT statements.

Example:

INPORT=Read.IN:FILENAME
Read(ReadFile) OUT -> IN Display(Output)

This line would export the IN port of the Read node as FILENAME.

Node metadata

It is possible to append metadata to Nodes when declaring them by adding the metadata string to the Component part after a colon (:).

Example:

'somefile.txt' -> SOURCE Read(ReadFile:main)
Read() OUT -> IN Split(SplitStr:main)
Split() OUT -> IN Count(Counter:main)
Count() COUNT -> IN Display(Output:main)
Read() ERROR -> IN Display()

In this case the route leading from Read to Display through Split and Count would be identified with the string main. You can also provide arbitrary metadata keys with the = syntax:

Read() OUT -> IN Split(SplitStr:foo=bar,baz=123)

In this case the Split node would contain the metadata keys foo and baz with values bar and 123.

Annotations

FBP graphs also support annotations for specifying things like graph name, description, icon, or the FBP runtime to be used for executing the graph.

The syntax for annotations is # @name value, for example:

# @runtime noflo-nodejs
# @name ReadSomefile
'somefile' -> SOURCE Read(ReadFile)

fbp's People

Contributors

aretecode avatar bergie avatar chadrik avatar d4tocchini avatar dependabot[bot] avatar djebbz avatar ensonic avatar forresto avatar greenkeeper[bot] avatar greenkeeperio-bot avatar ifitzpatrick avatar jonnor avatar kenhkan avatar leuisken avatar tlrobinson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fbp's Issues

Allow numbers in port, component and node names

In electronics it is quite common to have numbers in parts, and to use numbers pins and components (in the electronics meaning). Therefore I'd like to be able to expess these things in .fbp for MicroFlo.

No error on connecting to non-existing processes

Example:

right(MyComponent)
'data' -> IN almostright

Expected: Error that trying to attach IIP 'data' to non-existing process 'almostright'

Similar probably happens for port connections

Actual: No error

Visualize lowercases port names

Visualize lowercases port names. However I had understood from @bergie (maybe I misunderstood) that NoFlo only lowercases port names in generated JSON. I guess it doesn't matter much, as I believe that port names are case-insensitive, but it would be nice to see on the diagram what you actually typed in (same applies to array notation)!

ENTER both splits lines and starts the display

When using Visualize, ENTER both splits lines and starts the display, so you have to make sure the cursor is at the end of the network definition - this is really frustrating, as it is much more natural to make a change and then immediately hit ENTER! It looks as though Visualize needs a Send button!

Counter-commands for interactive mode

We're thinking of doing a FBP syntax REPL for modifying NoFlo graphs. In that case you'll want to do regular operations as you do in FBP, line-by-line:

Foo OUT -> IN Bar

But you'll also want to be able to counter them later. So to remove the connection made above, you could utilize a syntax like:

Foo OUT -X> IN Bar

Deprecate EXPORT keyword

We've had support for disambiguated INPORT and OUTPORT keywords for years now. It would be good to deprecate the old "we don't know which one this is" EXPORT keyword

Allow anonymous nodes

It would be convenient sometimes to not have to specify a node identifier when instantiating components.
The typical example encountered in MicroFlo is converting between active=true convention (inside the program) and active=LOW (on the edges of the hardware because that is how the connected electronics works).

E.g.
switch() OUT1 -> IN ia(InvertBoolean) OUT -> IN turnOn(DigitalWrite)
would become:
switch() OUT1-> IN (InvertBoolean) OUT -> IN turnOn(DigitalWrite)

Syntax highlighting in editors ?

May not be the best palce to ask, but do you guys have syntax highlighting of fbp files in your favorite editors ? I'm using Sublime Text (2/3) and couldn't find an official fbp syntax highlighter. Would make life easier (although it's not top-priority and could be something made by the community).

An in-range update of coveralls is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency coveralls was updated from 3.0.9 to 3.0.10.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

coveralls is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).

Release Notes for CodeFresh support, Maintenance

Added:

  • CodeFresh support (@suda)

Improved:

Updated:

Commits

The new version differs by 6 commits.

  • 2ea7be3 bump version
  • 5e976c5 Only coverage report on test success, fixes #230
  • 3d83b4f Set service_name and/or repo_token from .coveralls.yml regardless of if $COVERALLS_REPO_TOKEN is set (#272)
  • 710c504 Add Codefresh support
  • 8c4ba99 CI: switch to actions/checkout@v2
  • eb1a3c9 278 Upgrades minimist dependency to 1.2.5

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Allow addressing ArrayPorts

Currently in FBP connections to ArrayPorts are assigned to indexes based on order in the file.

As noted in noflo/noflo#128 we should also allow specifying indexes in FBP:

Foo OUT[0] -> IN[1] Bar

fbp lowercases port names

This causes a problem when using them as graphs since the-graph (somewhere) then duplicates the ports, with the duplicate being named in uppercase.

Please consider maintaining the case of the port names, or changing noflo.graph.loadFBP() to convert them back to uppercase.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

No error on missing component name

'localhost' -> IN instanceMissingComponentName OUT -> (core/Output)

Expected: Error mentioning that process instanceMissingComponentName has no component name defined

Actual: No error

Component / Process parsing doesn't allow [0-9_]

Changing ReadFile process in this example with : read_file, read2file

fbp.parse "'somefile.txt' -> SOURCE ReadFile(ReadFile) OUT -> IN Split(SplitStr)"

-> Ok

fbp.parse "'somefile.txt' -> SOURCE read_file(ReadFile) OUT -> IN Split(SplitStr)"

-> Nok

fbp.parse "'somefile.txt' -> SOURCE read2file(ReadFile) OUT -> IN Split(SplitStr)"

-> Nok

An in-range update of grunt is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency grunt was updated from 1.0.4 to 1.1.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

grunt is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push: The Travis CI build is in progress (Details).
  • continuous-integration/appveyor/branch: AppVeyor build failed (Details).

Release Notes for v1.1.0
  • Update to mkdirp ~1.0.3
  • Only support versions of Node >= 8
Commits

The new version differs by 8 commits.

  • d5cdac0 Merge pull request #1706 from gruntjs/tag-neew
  • 4674c59 v1.1.0
  • 6124409 Merge pull request #1705 from gruntjs/mkdirp-update
  • 0a66968 Fix up Buffer usage
  • 4bfa98e Support versions of node >= 8
  • f1898eb Update to mkdirp ~1.0.3
  • 75da17b HTTPS link to gruntjs.com (#1683)
  • 6795d31 Update js-yaml dependecy to ~3.13.1 (#1680)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Problems with array ports when parsing several connections in a line

Example of the graph:

'test 1' -> IN[0] Mux(mux) OUT[0] -> IN Display(console)
'test 2' -> IN[1] Mux OUT[1] -> IN Display

Result:

noflo/fbp/lib/fbp.js:1727
throw new this.SyntaxError(
^
SyntaxError: Expected " " or [a-zA-Z0-9_] but "-" found.

Put a single connection with array ports in a line works fine.

Support serializing JSON to .fbp

Basically the inverse of parse(). Should round-trip all information losslessly, which might require some additions, particularly node/edge/graph metadata.
Ideally would be able to preserve formatting of editing .fbp files to, but that is secondary.

Requested by @aretecode

Commas to separate multi-statements on single line

As suggested by @jpaulm

c:\threadn\pompiers.fil' -> OPT Lire() OUT -> IN Select() OUT -> IN Ecrire() Select() REJECT -> IN Ecrire2() ... and so on is tough to scan! Should become:

c:\threadn\pompiers.fil' -> OPT Lire OUT -> IN Select OUT -> IN Ecrire, Select REJECT -> IN Ecrire2 ... and so on

Readme out of date

The Readme still says that process names without the component specification require empty brackets. This seems to be no longer the case. Could someone change the Readme...? Thanks.

JSON to FBP problem

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

Would like to have a title within the file

I have some (old) NoFlo JSON which has something called "name" within "properties". I guess this can be obtained from the file name, but tools like Visualize accept input from a panel or textarea, so it would be nice to have a convention for specifying the file name, right in the network definition.

In the pre-NoFlo .fbp notation, we could specify xxx: at the beginning of the network, and also use the same convention for subnets, which could be included within the same file, if desired, separated by semi-colons.

Comments, @bergie @jonnor @forresto ?

default ports

Having repeated IN/OUT for components that simply have one in and one out seems overly verbose.

Instead of lots of IN/OUT you could simply declare that A -> B -> C would use whatever the 'default' input and output ports are. Could restrict this type of declaration for components with only one in and one out port.

Allow sending other valid JSON types as IIPs

Currently the FBP parser only allows strings to be defined as IIPs, but other types are also necessary.

Examples:

1 -> IN SomeNode
true -> OPEN Gate
['foo', 'bar'] -> IN OtherNode

Whitespace after process name generates new name

Example:

name(ComponentA)
shouldbename (ComponentB)

Expected: Either the instance of ComponentB is given identifier 'shouldbename', OR an error is raised that this is invalid.

Actual: The instance of ComponentB gets assigned a random identifier (as if it was an anonymous)

Add support for automatic ports

FBP defines automatic ports diagramatically and functionally, but there doesn't appear to be defined support for them in the DSL.

I propose that they be represented by an asterisk in place of an explicit name. This is in line with conventions set by JavaFBP.

Language agnostic test suite and grammar

I'm currently developing a Python FBP runtime focused on brevity meant to be a building block for more complex architectures. I wrote a PEG based parser for FBP DSL and I'm looking for as many examples as I could find to incorporate them into my test suite. What do you think about a language agnostic repo for test data just like some folks did for TOML:

https://github.com/BurntSushi/toml-test

In that repo you can find lots of valid and invalid test cases, extremely time saving for someone who's writing an encoder/decoder.

The same thing goes for the language specification: snooping around in your projects here on GitHub, I guessed that some language features are obscure to say at least, and a proper language specification is missing. This FBP language repo could become a place where to find a proper grammar (EBNF?), links to known parsers, etc.

Declare components before connecting them.

Declaration and connection could be split to reduce clutter.
Example:

Reader(filesystem/ReadFile) #read the invoices file
ReportGenerator(foo/Reportgen) #generate reports for the invoice
Printer(core/Output) #show results

'invoice.txt' -> IN Reader OUT -> IN ReportGenerator OUT -> IN Printer

Predeclared components without port names can be defaulted to the IN and OUT ports accordingly because they are the most common ports.

So it would look like this:

'invoice.txt' -> Reader -> ReportGenerator -> Printer

An in-range update of grunt-noflo-browser is breaking the build 🚨

Version 1.4.0 of grunt-noflo-browser was just published.

Branch Build failing 🚨
Dependency grunt-noflo-browser
Current Version 1.3.2
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

grunt-noflo-browser is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build is in progress Details
  • continuous-integration/appveyor/branch AppVeyor build failed Details

Commits

The new version differs by 8 commits.

  • 49cbe83 Bump
  • f6ac38e Merge pull request #30 from noflo/noflo_component_loader
  • 9935b00 Try to match also Windows paths with regexp
  • c188098 Bump noflo-component-loader dep
  • 84cec54 Update to legacy-free component versions
  • 821de79 Test on modern Node.js
  • ea16584 Use noflo-component-loader to build the loader
  • f00089b Remove obsolete grunt-noflo-manifest

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

syntax for grouping

When I do:

# In the graph we first need to define the nodes and the connections between them

Read(filesystem/ReadFile) OUT -> IN Parse(strings/ParseJson) OUT -> IN Extract1(objects/ExtractProperty) OUT -> IN Display(core/Output)

# Configure Extract
'dependencies' -> KEY Extract1
'noflo' -> KEY Extract1

# Start off the graph by sending a filename to the file reader
'package.json' -> IN Read

I get:

DATA -> KEY Extract1() CONN
DATA -> KEY Extract1() DATA
DATA -> KEY Extract1() DISC
DATA -> KEY Extract1() CONN
DATA -> KEY Extract1() DATA
DATA -> KEY Extract1() DISC

what I want is

DATA -> KEY Extract1() CONN
DATA -> KEY Extract1() DATA
DATA -> KEY Extract1() DATA
DATA -> KEY Extract1() DISC

Is there a syntax for it already? According to the tests there is not.

Newline only allowed at end of clause

Based on the behaviour of Visualize, it seems that newlines are only accepted at end of clause. I feel this should be part of the spec for the .fbp notation - if you agree, it would be good if someone could add it to the Readme. Thanks.

Cannot parse negative numbers

I might be wrong, but it seems the parser cannot deal with negative numbers :

-1 -> BEGIN LastGraph(objects/SliceArray)

fails with :

Fatal error: Expected " ", "#", "'", "EXPORT=", "INPORT=", "OUTPORT=", [A-Z.0-9_], [\n\r\u2028\u2029] or [a-zA-Z0-9_] but "-" found.

Parse `# @runtime` foo

FBP file with

# !runtime msgflo

should become in the JS/JSON representation

properties.environment.runtime: "foo" 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.