Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nora Puchreiner
Nix
Commits
9d25466b
Commit
9d25466b
authored
21 years ago
by
Eelco Dolstra
Browse files
Options
Downloads
Patches
Plain Diff
* An attribute set update operator (//). E.g.,
{x=1; y=2; z=3;} // {y=4;} => {x=1; y=4; z=3;}
parent
6d46e647
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/libexpr/eval.cc
+16
-0
16 additions, 0 deletions
src/libexpr/eval.cc
src/libexpr/lexer.l
+1
-0
1 addition, 0 deletions
src/libexpr/lexer.l
src/libexpr/parser.y
+2
-0
2 additions, 0 deletions
src/libexpr/parser.y
with
19 additions
and
0 deletions
src/libexpr/eval.cc
+
16
−
0
View file @
9d25466b
...
...
@@ -134,6 +134,18 @@ ATerm expandRec(ATerm e, ATermList rbnds, ATermList nrbnds)
}
static
Expr
updateAttrs
(
Expr
e1
,
Expr
e2
)
{
/* Note: e1 and e2 should be in normal form. */
ATermMap
attrs
;
queryAllAttrs
(
e1
,
attrs
);
queryAllAttrs
(
e2
,
attrs
);
return
makeAttrs
(
attrs
);
}
string
evalString
(
EvalState
&
state
,
Expr
e
)
{
e
=
evalExpr
(
state
,
e
);
...
...
@@ -264,6 +276,10 @@ Expr evalExpr2(EvalState & state, Expr e)
if
(
atMatch
(
m
,
e
)
>>
"OpOr"
>>
e1
>>
e2
)
return
makeBool
(
evalBool
(
state
,
e1
)
||
evalBool
(
state
,
e2
));
/* Attribut set update (//). */
if
(
atMatch
(
m
,
e
)
>>
"OpUpdate"
>>
e1
>>
e2
)
return
updateAttrs
(
evalExpr
(
state
,
e1
),
evalExpr
(
state
,
e2
));
/* Barf. */
throw
badTerm
(
"invalid expression"
,
e
);
}
...
...
This diff is collapsed.
Click to expand it.
src/libexpr/lexer.l
+
1
−
0
View file @
9d25466b
...
...
@@ -57,6 +57,7 @@ inherit { return INHERIT; }
\&\& { return AND; }
\|\| { return OR; }
\-\> { return IMPL; }
\/\/ { return UPDATE; }
{ID} { yylval->t = ATmake("<str>", yytext); return ID; /* !!! alloc */ }
{INT} { int n = atoi(yytext); /* !!! overflow */
...
...
This diff is collapsed.
Click to expand it.
src/libexpr/parser.y
+
2
−
0
View file @
9d25466b
...
...
@@ -42,6 +42,7 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, void * data, char * s)
%left OR
%left AND
%nonassoc EQ NEQ
%right UPDATE
%left NEG
%%
...
...
@@ -69,6 +70,7 @@ expr_op
| expr_op AND expr_op { $$ = ATmake("OpAnd(<term>, <term>)", $1, $3); }
| expr_op OR expr_op { $$ = ATmake("OpOr(<term>, <term>)", $1, $3); }
| expr_op IMPL expr_op { $$ = ATmake("OpImpl(<term>, <term>)", $1, $3); }
| expr_op UPDATE expr_op { $$ = ATmake("OpUpdate(<term>, <term>)", $1, $3); }
| expr_app
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment