1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-28 17:51:15 +02:00

Allow the leading component of a path to be a ~

This commit is contained in:
Shea Levy 2015-02-19 08:05:16 -05:00
parent 1816ac0db1
commit e0953d53de
3 changed files with 19 additions and 2 deletions

View file

@ -268,7 +268,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err
%token <id> ID ATTRPATH
%token <e> STR IND_STR
%token <n> INT
%token <path> PATH SPATH
%token <path> PATH HPATH SPATH
%token <uri> URI
%token IF THEN ELSE ASSERT WITH LET IN REC INHERIT EQ NEQ AND OR IMPL OR_KW
%token DOLLAR_CURLY /* == ${ */
@ -376,6 +376,14 @@ expr_simple
$$ = stripIndentation(CUR_POS, data->symbols, *$2);
}
| PATH { $$ = new ExprPath(absPath($1, data->basePath)); }
| HPATH {
auto path = string{$1 + 1};
$$ = new ExprConcatStrings(CUR_POS, false, new vector<Expr *>{
new ExprPath("/"),
new ExprApp(new ExprVar(data->symbols.create("__getEnv")),
new ExprString(data->symbols.create("HOME"))),
new ExprString(data->symbols.create(path))});
}
| SPATH {
string path($1 + 1, strlen($1) - 2);
$$ = new ExprApp(CUR_POS,