GithubHelp home page GithubHelp logo

isabella232 / bazel_rules Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jflex-de/bazel_rules

0.0 0.0 0.0 292 KB

Bazel rules to generate java files with JFlex

Home Page: https://jflex-de.github.io/bazel_rules/

License: Apache License 2.0

Lex 15.00% Java 37.19% Shell 3.95% Smarty 0.88% Starlark 42.40% SCSS 0.58%

bazel_rules's Introduction

Bazel rules for JFlex & Cup

This repository offers two rules for projects using the Bazel build system:

  • Rule to generate java source files from a lexer specification, with JFlex

  • Rule to generate java source files from a parser specification, with CUP

Project health

Status of the master branch: Build status

Disclaimer

This is not an officially supported Google product.

Prepare your Bazel workspace

Add a dependency on rules_jvm_external

See bazelbuild/rules_jvm_external.

Load the jflex rule

Load the bazel_rules in your WORKSPACE file and add JFLEX_ARTIFACTS in your maven_install rule:

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@rules_jvm_external//:defs.bzl", "maven_install")

http_archive(
    name = "jflex_rules",
    sha256 = "a4a9d59f39d4055c2deddd8058cf28baee916116a743d200c4bba58a13b9e184",
    strip_prefix = "bazel_rules-1.8.2",
    url = "https://github.com/jflex-de/bazel_rules/archive/v1.8.2.tar.gz",
)

load("@jflex_rules//jflex:deps.bzl", "JFLEX_ARTIFACTS")

maven_install(
    name = "maven",
    artifacts = JFLEX_ARTIFACTS,
    maven_install_json = "//:maven_install.json",
    repositories = [
        "https://jcenter.bintray.com/",
        "https://maven.google.com",
        "https://repo1.maven.org/maven2",
    ],
)

If this is the first time you use maven_install, you need to generate the maven_install.json with

bazel run @maven//:pin

If you already used maven_install before, you need to update the pinned artifacts with:

bazel run @unpinned_maven//:pin

Usage in BUILD files

load("@jflex_rules//jflex:jflex.bzl", "jflex")
load("@jflex_rules//cup:cup.bzl", "cup")

jflex(
    name = "",           # Choose a rule name
    srcs = [],           # A list of flex specifications
    outputs = [],        # List of expected generated files
)

cup(
    name = "",           # Choose a rule name
    src = "",            # Grammar specification
)

As usual, these rules can be used as one of the srcs of another rules, such as a java_library.

For more details, see cup and jflex.

Directory layout

├── assets                 → assets for the web site
├── cup                    → contains the `cup.bzl` Skylark extension
├── java                   → main Java source code
│   └── jflex
│       └── examples       → examples
│           ├── calculator → integration of JFlex and CUP
│           └── helloworld → simple lexer
├── javatests              → tests of the examples
├── jflex                  → contains the `jflex.bzl` Skylark extension
└── third_party            → Aliases for third-party libraries

bazel_rules's People

Contributors

regisd 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.