Commit graph

1307 commits

Author SHA1 Message Date
Ruud van Asseldonk
c104f06b8a Simplify the parser by adding an Eof token
I learned about this in one of Matklad's posts, it's a nice idea that
simplifies things a bit.
2024-08-24 12:30:59 +02:00
Ruud van Asseldonk
c51b77a59e Add 'rcl re' and 'rcl rq' shorthands for -fraw
This is somewhat common, especially when used as jq replacement, so
let's add a shorthand for them.
2024-08-23 22:14:41 +02:00
Ruud van Asseldonk
d6a4b48bee Point Zed extension at the newly published grammar
This is a bit annoying now, I have to dump them one by one and update
the repository url. But the format forces that. I could automate it
further, but for now it's okay to do by hand.
2024-08-02 23:20:28 +02:00
Ruud van Asseldonk
d9f0716b26 Merge Zed extension and repository tools
This adds some tools to keep external repositories in sync. They will
hold the Tree-sitter grammar and Zed extension. Perhaps in the future
I should move the Vim plugin out as well. Maybe the Zed extension and
Vim plugin can be submodules, but I quite like that I can update them
and see the diff in the same commit where I edit the grammar.
2024-08-02 23:13:57 +02:00
Ruud van Asseldonk
08725c60b0 Point Zed extension url at external repo 2024-08-02 23:12:53 +02:00
Ruud van Asseldonk
854ed62fe4 Enable exporting the Zed extension as well 2024-08-02 23:12:52 +02:00
Ruud van Asseldonk
82cf536c6f Add documentation about the grammars and testing 2024-08-02 23:12:18 +02:00
Ruud van Asseldonk
9105bb9f17 Add Tree-sitter highlights for Zed
Documentation is quite absent for Zed, but that is not stopping people
from developing extensions apparently.
2024-08-02 21:33:05 +02:00
Ruud van Asseldonk
8b4cadc0d3 Add an initial Zed extension
This has not been tested yet. Also, I may need to move it into a
separate repository, but we can do that in the same way as with the
Tree-sitter repo that I just extracted.
2024-08-02 21:33:05 +02:00
Ruud van Asseldonk
ce38b059e0 Finish initial version of tree-sitter-rcl dumper
It can generate commits, it's fine for now.
2024-08-02 21:33:05 +02:00
Ruud van Asseldonk
b0edb62363 Begin working on repository export script
I want to make a Zed extension, and it looks like Zed does not support
Tree-sitter grammars that do not live at the repository root, so let's
just make a separate repository to dump a generated copy of the grammar
in. It will also make integration with other Tree-sitter consumers
easier.
2024-08-02 21:33:05 +02:00
Dennis Frenken
d0e67ee480
Add golden test 2024-08-02 12:20:34 +02:00
Dennis Frenken
8f2b9bcfc6
Simplify message 2024-08-02 12:17:46 +02:00
Dennis Frenken
9d31417c50
Hint at using record syntax
In the expression `{ key: true }` (json syntax) `key` is interpreted as an
identifier whereas in `{ key = true }` (record syntax) `key` is a string literal.

This hint should highlight that possible syntax mixup.
2024-08-01 14:40:11 +02:00
Ruud van Asseldonk
2d5cd372dc Begin collecting meanings of the name "RCL"
I just encountered "Reduce Cognitive Load" in a comment on Hacker News
and it fits the acronym very well, I'm going to keep a list of possible
meanings of the name "RCL".
2024-07-31 22:09:23 +02:00
Ruud van Asseldonk
54e30bdbb6 Merge syntax change for comma after "else"
Ever since 8d4d61e2f1, I was unsure about
whether there should be a colon after else. It looks more natural in
the multi-line form for sure, but it looks weird in the single-line
form. But the single-line form looks a bit awkward anyway, and having
the colon feels more regular. It also creates more line noise though,
it is strictly not needed. Etc.

After having stared at RCL code for half a year now, my feeling is that
the colon should be there after all. Nim was right all along.

So support a colon after else, but make it optional for now. Do make it
the default, in the sense that the docs and autoformatter use it.
2024-07-31 22:01:06 +02:00
Ruud van Asseldonk
05ceea94c0 Use new if-else syntax in Smith fuzzer
It means the fuzzer gets to explore less, actually, but we still have
the source-based fuzzer that will find the case where the colon is
missing, and which could hunt for non-idempotencies in the formatter and
such.
2024-07-31 21:53:58 +02:00
Ruud van Asseldonk
1389f7c7a5 Mention if-else syntax change in the changelog 2024-07-31 21:46:23 +02:00
Ruud van Asseldonk
414b9c5051 Update docs to use new if-else syntax 2024-07-31 21:46:23 +02:00
Ruud van Asseldonk
9270454952 Make autoformatter add colon after else by default 2024-07-31 21:46:23 +02:00
Ruud van Asseldonk
816a00745f Optionally allow a colon after "else" in grammar
When I initially converted from the "if-then-else" keyword syntax to the
colon-based one, during development I put the colon in, then later I
removed it again, but I was still unsure. Now, after having used the
syntax for some time, my feeling is that there should be a colon after
all. Nim got it right. So put it back.

Because it's easy to stay backwards compatible here, make the colon
optional. We can make it mandatory at some point in the future, but even
making the autoformatter put it there is probably a strong enough push.
2024-07-31 21:46:23 +02:00
Ruud van Asseldonk
28d920e4ac Bump version to 0.5.0 2024-07-28 21:43:29 +02:00
Ruud van Asseldonk
87e379cd87 Merge the new "rcl build" subcommand
Background

I previously added support for depfiles to enable Ninja to update generated
files. But defining a build file like that has some overhead, and introduces
yet another tool. For small things like generating two GitHub Actions workflow
files, adding a build system seems overkill, so I just wrote a shell script.
But then I still needed to split the configuration into multiple files and add
a shell script.

Solution

Add some limited support for defining generated files in RCL itself. This is
not intended to replace a full-blown build tool, more as an intermediate step
to lower the barrier to rewriting configurations in RCL. For many small use
cases, like my two workflows above, we don’t need more than this.

Timeline

I started working on this in February and got it into a pretty good state, but
then never put in the finishing touches. Then I got sidetracked with the type
system blog post series. Now that all that is out of the way, let's integrate
this and make a new release.
2024-07-27 23:03:17 +02:00
Ruud van Asseldonk
14cedbe90e Add friendly message for build IO error 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
75114ade17 Correct help text for "rcl build" schema 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
d096139541 Improve the Ninja documentation
Previously we named the file "build.rcl", but now that that is the
default name for "rcl build", let's name the Ninja meta build file
"ninja.rcl". Also, clarify that Make is able to use the depfiles too,
just in a way that I personally try to stay far away from.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
e7f6f21700 Document new "rcl build" command in changelog 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
12ffe62cf4 Address a few minor issues in the new build code
Caught in self-review, and I don't feel like turning them into fixups
for all of the commits that introduced these.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
7c8382ab3d Update Ninja docs chapter to match "rcl build" 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
31f7c07176 Write docs chapter about "rcl build" usage
This is somewhat of an alternative to the Ninja chapter, I still need to
update that one.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
768d44546f Simplify highlighting output paths in errors 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
73413a99d5 Handle sandbox policy and IO errors in build output
Report errors properly. This is quite verbose, I should make some
shorthands for formatting paths. Also check the sandbox policy while
we create the output path.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
c611c0f28d Add more goldens to cover build subcommand 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
948cb80d6e Ensure golden tests again don't write files
This makes the golden tests for "rcl buidl" work with the Nix sandbox.
Instead of really writing to output files, we use the new --dry-run
option. This simplifies the test runner and clutters the repository
less. Splitting out IO is ususally a good thing.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
eabf7f267c Add tests for "rcl build" CLI parsing 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
0831fda447 Add --dry-run option to "rcl build"
As expected, the golden tests fail to run under Nix because the test
directory is not writable. And it's better to not write in my opinion,
let's not hack that and have a dry run output mode.

For now the output format is not structured, this is good enough for the
thests. It could be nice to do structured output in RCL format, but we
can do that later if needed.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
c5e2802c58 Add golden tests for "rcl build" command
I am a bit hesitant about making the tests write to the file system.
Maybe I should add a --dry-run mode to "rcl build" that instead prints
what files it would write to and what contents. But then we test less
of the real implementation, and there is something to say for testing
the real thing as much as possible, so let's do this for now. It may
cause trouble for the Nix flake checks, but outside of the Nix flake
it works.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
db69504ccf Allow banner in build config to be null
I don't like this distinction that in the build file, we don't
implicitly add a newline, but on the command line we do. But making
users specify a trailing newline on the command line is annoying. So
then the RCL build spec will have to match the CLI, and append the
newline. But then empty string cannot be the default, so let's accept
null too.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
4a2a58c5ff Restructure the 'rcl build' help text 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
56a0737349 Remove default value for 'format' in build
There is no good default value, and there is no reason this should have
a default, if you generate files, you are expecting some particular
format!
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
0f29c2745a Chdir to examples directory first in flake tests
My new build example is failing due to the sandbox policy. So at least
that is working!
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
2ac766a101 Extend 'rcl build' docs a bit 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
207d8c75bd Simplify banner support in 'rcl build'
I couldn't add a banner to the GitHub Actions yaml because the output
format is json which does not support comments. By making the banner
just a string that is up to the user to fill, everything becomes both
simpler and more general.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
6b1a8bce1c Print status from 'rcl build'
Classic Unix tools are silent on success, but I do like to know how much
it wrote. I can imagine the output would become verbose and I'd rather
have one status line like Ninja. But for now this is okay.
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
00374ab6a0 Implement first rudimentary version of 'rcl build'
It can now build the build file in the examples!
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
80ba83e678 Add build target parsing
Wow, writing a proper deserializer for an RCL value is still a lot of
work, even in Rust! I should write a #[derive] macro for it. But having
record types would make this a lot easier already, so let's wait with
that. For now it's hand-written with a dozen error messages that I will
need to add goldens for ...
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
f9014cb1ef Add entry point for 'rcl build' command 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
8e0465c73c Elaborate a bit in "rcl build" docs 2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
85cba66c7d Add docs for new 'rcl build' subcommand
Readme-driven development here, the command doesn't exist yet!
2024-07-27 23:03:05 +02:00
Ruud van Asseldonk
38cc285d65 Add and fix links in the documentation index 2024-07-22 23:36:01 +02:00