repl: Always use parser, allow trailing ; in assignments
We now properly shell out to the parser instead of hacking stuff together with a regex. Stuff we get for free by doing this: - Optional trailing semicolon - Declaring nested attribute sets - String identifiers, and future proofing for eventual grammar improvements to identifiers - Dynamic attributes Change-Id: Ibf1ad815e5e27caf162df05ea5ba5b1b4955d9c9
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
@args -v
|
||||
Adding variables gives simple user feedback
|
||||
|
||||
Lix $VERSION
|
||||
Type :? for help.
|
||||
nix-repl> foo = 5
|
||||
Added foo.
|
||||
|
||||
nix-repl> foo = 10
|
||||
Updated foo.
|
||||
|
||||
Optional semicolon at the end, allow setting multiple variables in one line
|
||||
|
||||
nix-repl> foo = 2;
|
||||
Updated foo.
|
||||
|
||||
nix-repl> foo = 2; bar = 3;
|
||||
Updated foo.
|
||||
Added bar.
|
||||
|
||||
String identifiers work
|
||||
|
||||
nix-repl> "silly name" = null
|
||||
Added "silly name".
|
||||
|
||||
Attrset syntax works, but without dynamic attrs or merging
|
||||
|
||||
nix-repl> foo.bar = "baz"
|
||||
Updated foo.
|
||||
|
||||
nix-repl> foo
|
||||
{ bar = "baz"; }
|
||||
|
||||
nix-repl> foo."this works" = 42
|
||||
Updated foo.
|
||||
|
||||
nix-repl> foo
|
||||
{ "this works" = 42; }
|
||||
|
||||
nix-repl> foo.bar = "baz"; foo.more = "error"
|
||||
error: attribute 'foo' already defined at «string»:1:18
|
||||
at «string»:1:12:
|
||||
1| foo.bar = "baz"; foo.more = "error"
|
||||
| ^
|
||||
|
||||
nix-repl> ${foo} = 10
|
||||
error: dynamic attributes not allowed in REPL
|
||||
at «string»:1:1:
|
||||
1| ${foo} = 10
|
||||
| ^
|
||||
Reference in New Issue
Block a user