Git Product home page Git Product logo

signalflow-grammar's Introduction

SignalFlow language grammar

This repository contains the SignalFx SignalFlow language grammar and the structure and tools required to generate the public code artifacts that make this grammar available in various languages.

The language is in ANTLR4 format and we use the antlr tool to generate the corresponding source code for the target languages. From there, we can build artifacts that can be included as dependencies in various projects that need to parse SignalFlow programs.

Note: if you're looking to use the grammar, you should use one of the generated artifacts instead of this repository.

Available languages

Java

The com.signalfx.public:signalflow-grammar artifact Jar is available on Maven Central:

<dependency>
  <groupId>com.signalfx.public</groupId>
  <artifactId>signalflow-grammar</artifactId>
  <version>2.12.0</version>
</dependency>

Javascript

The library is available for npm.js, and as a standalone browserified Javascript bundle.

Node.js

npm install -g signalflow-grammar.js

In browser

<script type="text/javascript" src="https://s3.amazonaws.com/public-sites--signalfx-com/cdn/signalflow-grammar-2.7.0.js"></script>

Python

The library is available on PyPI and depends on the Python2 ANTLR runtime:

$ pip install signalflow-grammar==2.7.0

Then, from your code, you can do:

import antlr4
from signalflow.grammar.SignalFlowV2Lexer import SignalFlowV2Lexer
from signalflow.grammar.SignalFlowV2Parser import SignalFlowV2Parser

def parse(program):
    lexer = SignalFlowV2Lexer(program)
    stream = antlr4.CommonTokenStream(lexer)
    parser = SignalFlowV2Parser(stream)
    ...

Generating or updating the artifacts

Due to the Python like nature of SignalFlow some native code is required to keep track of indent/dedent levels. This native code is stored in <language>/grammar/*.g4. These native code files are stitched into SignalFlowLexer.g4 by the generate_grammar.py script.

Update the generated source code with the generate.sh script:

$ ./generate.sh <version>
$ git commit -a -m "Bump to version <version>"
$ git push origin master

Then for each language, perform a release of the corresponding package.

Java

$ cd java/
$ mvn clean deploy -P release-sign-artifacts -DperformRelease=true -DrepositoryId=ossrh -Dgpg.useagent=false

Javascript

$ cd javascript/
$ npm publish
$ aws s3 cp signalflow-grammar-<version>.js s3://public-sites--signalfx-com/cdn/

Python

$ cd python/
$ python setup.py bdist_wheel
$ twine upload dist/signalflow_grammar-<version>-py2-none-any.whl

signalflow-grammar's People

Contributors

tedoc2000 avatar mpetazzoni avatar rajeshraman avatar

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.