Move parser to solely use $ for variables for 2021 edition support #27
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We have to stop using
#
as a delimiter, because the 2021 edition reserved any identifier-prefixed#
tokens making expressions like these no longer be legal:This would be seen as the
hello#world
token by Rust 2021, and since thehello
prefix is not recognized by the Rust compiler and would not compile. See https://doc.rust-lang.org/edition-guide/rust-2021/reserving-syntax.html for more.$
does not suffer from this (and is more in the spirit of macros) so we're now moving all syntax to use it even if that means it's a bit more verbose.This implements the following parser changes:
#var
is now$var
.#(var + 5)
is now$(var + 5)
#_(hello world)
is now$[str](hello world)
.#_(hello $world)
is now$[str](hello $world)
(runtime evaluation, like havinghello ${world}
in javascript).#_(hello $(world + 1))
is now$[str](hello $(world + 1))
(runtime evaluation, like havinghello ${world + 1}
in javascript).#_(hello #world)
is now$[str](hello $[const](world))
(compile time evaluation, whatever valueworld
has will become a component of the generated string).The following control sequences are changed:
#<space>
becomes$[' ']
#<push>
becomes$['\r']
.#<line>
becomes$['\n']
.This change will be part of the
genco
0.17 release.