Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Bazel rules to generate java files with JFlex

License

NotificationsYou must be signed in to change notification settings

jflex-de/bazel_rules

Repository files navigation

This repository offers two rules for projects using theBazel build system:

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

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

Project health

Status of themaster branch:Build status

Disclaimer

This is not an officially supported Google product.

Prepare your Bazel workspace

Add a dependency on rules_jvm_external

Seebazelbuild/rules_jvm_external.

Load the jflex rule

Load thebazel_rules in yourWORKSPACE fileand addJFLEX_ARTIFACTS in yourmaven_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 = "c4d68bde12f47af86b6f80a34dd55c67e82cf77b7ff2317cb472c07b1d09a6da",    strip_prefix = "bazel_rules-1.9.1",    url = "https://github.com/jflex-de/bazel_rules/archive/v1.9.1.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 usemaven_install, you need to generate themaven_install.json with

bazel run @maven//:pin

If you already usedmaven_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 thesrcs of another rules, such as ajava_library.

For more details, seecup andjflex.

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

[8]ページ先頭

©2009-2025 Movatter.jp