Bazel rules to generate java files with JFlex
Clone or download
regisd Change CUP rule to Skylark rule (#10)
* Replace genrule by Skylark rule

**NB** cup() must return the depset of generated files, otherwise bazel thinks there is nothing to do

* Add a fake cup

  Just a script that shows args and produces empty files

* Add tests for the example custom_bin using fake_cup_bin

* Add alias //cup:cup_bin

* Modernize syntax of jflex rule too
Latest commit 853335a Oct 17, 2018
Permalink
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Oct 10, 2018
assets Use git-hup pages to publish README Oct 9, 2018
cup Change CUP rule to Skylark rule (#10) Oct 17, 2018
java Change CUP rule to Skylark rule (#10) Oct 17, 2018
javatests Change CUP rule to Skylark rule (#10) Oct 17, 2018
jflex Change CUP rule to Skylark rule (#10) Oct 17, 2018
third_party Add Bazel rule for java_cup (#6) Oct 15, 2018
.bazelproject
.cirrus.bazelrc Add configuration for Cirrus-CI Oct 10, 2018
.cirrus.yml Add configuration for Cirrus-CI Oct 10, 2018
.gitignore
BUILD Change CUP rule to Skylark rule (#10) Oct 17, 2018
CODEOWNERS
LICENSE Initial commit Oct 9, 2018
README.md
WORKSPACE Add Bazel rule for java_cup (#6) Oct 15, 2018
_config.yml Use git-hup pages to publish README Oct 9, 2018

README.md

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

Load the bazel_rules in your WORKSPACE file:

load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
        name = "jflex_rules",
        remote = "https://github.com/jflex-de/bazel_rules.git",
        branch = "stable",
)

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

# If you want to use JFlex.
jflex_deps()

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