[pkgs/peggy] unify arguments to peggy parser (#145585)

We're getting closer to building peggy outside of bazel, and would like
to make configuring peggy something that is file-specific and not done
by configuring a peggy cli flag. This pr moves the config to
`${basename}.config.json` and then loads that in the cli instead. Down
the road we'll be able to write wrappers around the peggy compiler which
automatically picks up that file when it's located right next to the
grammar.
This commit is contained in:
Spencer 2022-11-17 15:04:23 -07:00 committed by GitHub
parent 6d4cadaeac
commit c573527fc2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 5 deletions

View file

@ -62,12 +62,13 @@ TYPES_DEPS = [
peggy(
name = "grammar",
data = [
":grammar/grammar.peggy"
":grammar/grammar.peggy",
":grammar/grammar.config.json"
],
output_dir = True,
args = [
"--allowed-start-rules",
"start,Literal",
"--extra-options-file",
"./%s/grammar/grammar.config.json" % package_name(),
"-o",
"$(@D)/built_grammar.js",
"./%s/grammar/grammar.peggy" % package_name()

View file

@ -0,0 +1,3 @@
{
"allowedStartRules": ["start", "Literal"]
}

View file

@ -66,12 +66,13 @@ jsts_transpiler(
peggy(
name = "grammar",
data = [
":grammar/grammar.config.json",
":grammar/grammar.peggy"
],
output_dir = True,
args = [
"--allowed-start-rules",
"expression,argument",
"--extra-options-file",
"./%s/grammar/grammar.config.json" % package_name(),
"-o",
"$(@D)/built_grammar.js",
"./%s/grammar/grammar.peggy" % package_name()

View file

@ -0,0 +1,3 @@
{
"allowedStartRules": ["expression", "argument"]
}