Skip to content

Commit

Permalink
Remove debug logs (#27)
Browse files Browse the repository at this point in the history
* Remove print (aka DEBUG log) in jflex() rule

* Make JFlex generation quiet by default.

* Make CUP generation quiet.

* Make the nested_grammar example non quiet.

It outputs
```
INFO: From jflex java/jflex/examples/nested_grammar/NestedRulesScanner.java:
Reading "java/jflex/examples/nested_grammar/nested_grammar.jflex"
Including "java/jflex/examples/nested_grammar/extra-jflex-rules.inc.jflex"
Constructing NFA : 18 states in NFA
Converting NFA to DFA :
............
14 states before minimization, 13 states in minimized DFA
Writing code to "bazel-out/darwin-fastbuild/bin/java/jflex/examples/nested_grammar/NestedRulesScanner.java"
```
  • Loading branch information
regisd authored Jan 8, 2021
1 parent 3322036 commit 604dd84
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cup/cup.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ def _cup_impl(ctx):
args.extend(["-parser", ctx.attr.parser])
args.extend(["-symbols", ctx.attr.symbols])
args.extend(["-destdir", output_dir])
args.extend(["-nosummary"])
if ctx.attr.interface:
args.append("-interface")
args.extend([ctx.file.src.path])

# TODO(regisd): Add support for CUP options.
print("cup " + (" ".join(args)))
parser_file = ctx.actions.declare_file(ctx.attr.parser + ".java")
sym_file = ctx.actions.declare_file(ctx.attr.symbols + ".java")
ctx.actions.run(
Expand Down
1 change: 1 addition & 0 deletions java/jflex/examples/nested_grammar/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jflex(
srcs = ["nested_grammar.jflex"],
data = ["extra-jflex-rules.inc.jflex"],
outputs = ["NestedRulesScanner.java"],
quiet = False,
)

java_library(
Expand Down
7 changes: 6 additions & 1 deletion jflex/jflex.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def _jflex_impl(ctx):
maybe_skel = [ctx.file.skeleton] if ctx.file.skeleton else []
arg_maybe_skel = ["-skel", ctx.file.skeleton.path] if ctx.file.skeleton else []
arg_maybe_jlex = ["--jlex"] if ctx.attr.jlex else []
arg_maybe_quiet = ["--quiet"] if ctx.attr.quiet else []
arguments = (
arg_maybe_skel +
arg_maybe_jlex +
arg_maybe_quiet +
# Option to specify output directory
["-d", output_dir] +
# Input files
Expand All @@ -36,7 +38,6 @@ def _jflex_impl(ctx):
executable = ctx.executable.jflex_bin,
arguments = arguments,
)
print("jflex " + (" ".join(arguments)))

jflex = rule(
implementation = _jflex_impl,
Expand All @@ -59,6 +60,10 @@ jflex = rule(
doc = "an optional skeleton",
),
"outputs": attr.output_list(allow_empty = False),
"quiet": attr.bool(
doc = "JFlex generation outputs error messages only",
default = True,
),
"jflex_bin": attr.label(
default = Label("//jflex:jflex_bin"),
executable = True,
Expand Down

0 comments on commit 604dd84

Please sign in to comment.