Closed taktoa closed 8 years ago
It's also worth noting that the following code is valid and evaluates to "foo bar baz\nquux"
:
"foo ${
"bar"
} baz
quux"
Perhaps it would be worthwhile for Nix to have an optional dependency on nlohmann/json that adds a --json
option to spit out the parsed AST of a given Nix expression, which editors could then use strategically.
I have verified that this bug occurs upstream as well.
:+1:
I can't quite figure out what's going on here.
Two other cases that are broken but should work are:
x = ''${asdf} '';
and
x = '' ${asdf}'';
The first one is something I broke trying to work out character escaping. The other one was always broken.
You may be interested in this issue I raised on Nix: https://github.com/NixOS/nix/issues/1102
Eventually I want to write a proper nix parser in elisp similar to how js2-mode works. Most likely I'd try not to use nix-instantiate so we don't have to deal with the external process.
Some notes on this issue:
${
like "
. Maybe we need to have a syntax property for old style ""
. The parser state seems to return "34" in these cases under slot 4 instead of the usual "t". See https://www.gnu.org/software/emacs/manual/html_node/elisp/Parser-State.html.x = ''${asdf}''
. This rule should be ignored when we are outside of a multiline string.Eventually I want to write a proper nix parser in elisp similar to how js2-mode works. Most likely I'd try not to use nix-instantiate so we don't have to deal with the external process.
If we do end up getting a BNFC grammar for Nix, it might be more efficient to just write a new elisp backend for BNFC (if one doesn't already exist).
This is all I've found: https://github.com/robstewart57/bnfc/commit/3bf49b354132a6eb47375c7e83eec30dcb2ddb54
A string of the form
gets blue highlighting for the initial
${
but otherwise is not correctly highlighted.Note that that is a double-quoted string (
"foo"
) rather than a double-single-quoted string (''foo''
), which has the correct behavior in nix-mode master.Example screenshot: