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
This is not an officially supported Google product.
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()
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.
├── 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