* Finally, a real "let" syntax: `let x = ...; ... z = ...; in ...'.
This commit is contained in:
parent
7581cfdee4
commit
ac19b333b3
|
@ -66,8 +66,8 @@ The hook `nix-mode-hook' is run when Nix mode is started.
|
||||||
|
|
||||||
|
|
||||||
(defvar nix-keywords
|
(defvar nix-keywords
|
||||||
'("\\<if\\>" "\\<then\\>" "\\<else\\>" "\\<assert\\>"
|
'("\\<if\\>" "\\<then\\>" "\\<else\\>" "\\<assert\\>" "\\<with\\>"
|
||||||
"\\<let\\>" "\\<rec\\>" "\\<inherit\\>"
|
"\\<let\\>" "\\<in\\>" "\\<rec\\>" "\\<inherit\\>"
|
||||||
("\\<true\\>" . font-lock-builtin-face)
|
("\\<true\\>" . font-lock-builtin-face)
|
||||||
("\\<false\\>" . font-lock-builtin-face)
|
("\\<false\\>" . font-lock-builtin-face)
|
||||||
("\\<null\\>" . font-lock-builtin-face)
|
("\\<null\\>" . font-lock-builtin-face)
|
||||||
|
|
|
@ -91,6 +91,7 @@ else { return ELSE; }
|
||||||
assert { return ASSERT; }
|
assert { return ASSERT; }
|
||||||
with { return WITH; }
|
with { return WITH; }
|
||||||
let { return LET; }
|
let { return LET; }
|
||||||
|
in { return IN; }
|
||||||
rec { return REC; }
|
rec { return REC; }
|
||||||
inherit { return INHERIT; }
|
inherit { return INHERIT; }
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ static void freeAndUnprotect(void * p)
|
||||||
%type <t> expr_app expr_select expr_simple bind inheritsrc formal
|
%type <t> expr_app expr_select expr_simple bind inheritsrc formal
|
||||||
%type <ts> binds ids expr_list formals string_parts
|
%type <ts> binds ids expr_list formals string_parts
|
||||||
%token <t> ID INT STR PATH URI
|
%token <t> ID INT STR PATH URI
|
||||||
%token IF THEN ELSE ASSERT WITH LET REC INHERIT EQ NEQ AND OR IMPL
|
%token IF THEN ELSE ASSERT WITH LET IN REC INHERIT EQ NEQ AND OR IMPL
|
||||||
%token DOLLAR_CURLY /* == ${ */
|
%token DOLLAR_CURLY /* == ${ */
|
||||||
|
|
||||||
%nonassoc IMPL
|
%nonassoc IMPL
|
||||||
|
@ -152,6 +152,8 @@ expr_function
|
||||||
{ $$ = makeAssert($2, $4, CUR_POS); }
|
{ $$ = makeAssert($2, $4, CUR_POS); }
|
||||||
| WITH expr ';' expr_function
|
| WITH expr ';' expr_function
|
||||||
{ $$ = makeWith($2, $4, CUR_POS); }
|
{ $$ = makeWith($2, $4, CUR_POS); }
|
||||||
|
| LET binds IN expr_function
|
||||||
|
{ $$ = makeSelect(fixAttrs(1, ATinsert($2, makeBind(toATerm("<let-body>"), $4, CUR_POS))), toATerm("<let-body>")); }
|
||||||
| expr_if
|
| expr_if
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
1
tests/lang/eval-okay-new-let.exp
Normal file
1
tests/lang/eval-okay-new-let.exp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Str("xyzzyfoobar")
|
14
tests/lang/eval-okay-new-let.nix
Normal file
14
tests/lang/eval-okay-new-let.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
let
|
||||||
|
|
||||||
|
f = z:
|
||||||
|
|
||||||
|
let
|
||||||
|
x = "foo";
|
||||||
|
y = "bar";
|
||||||
|
body = 1; # compat test
|
||||||
|
in
|
||||||
|
z + x + y;
|
||||||
|
|
||||||
|
arg = "xyzzy";
|
||||||
|
|
||||||
|
in f arg
|
Loading…
Reference in a new issue