From a60317f20fbc8be8e339060d932946f6d99ece6a Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 12 Apr 2010 21:21:24 +0000 Subject: * More missing constructs. --- src/libexpr/nixexpr.hh | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'src/libexpr/nixexpr.hh') diff --git a/src/libexpr/nixexpr.hh b/src/libexpr/nixexpr.hh index ebdfd0a152ca..d6e088c41661 100644 --- a/src/libexpr/nixexpr.hh +++ b/src/libexpr/nixexpr.hh @@ -24,6 +24,9 @@ struct Pos }; +std::ostream & operator << (std::ostream & str, const Pos & pos); + + /* Abstract syntax of Nix expressions. */ struct Env; @@ -81,6 +84,14 @@ struct ExprSelect : Expr COMMON_METHODS }; +struct ExprOpHasAttr : Expr +{ + Expr * e; + string name; + ExprOpHasAttr(Expr * e, const string & name) : e(e), name(name) { }; + COMMON_METHODS +}; + struct ExprAttrs : Expr { bool recursive; @@ -139,6 +150,21 @@ struct ExprIf : Expr COMMON_METHODS }; +struct ExprAssert : Expr +{ + Pos pos; + Expr * cond, * body; + ExprAssert(const Pos & pos, Expr * cond, Expr * body) : pos(pos), cond(cond), body(body) { }; + COMMON_METHODS +}; + +struct ExprOpNot : Expr +{ + Expr * e; + ExprOpNot(Expr * e) : e(e) { }; + COMMON_METHODS +}; + #define MakeBinOp(name, s) \ struct Expr##name : Expr \ { \ @@ -158,15 +184,17 @@ MakeBinOp(OpAnd, "&&") MakeBinOp(OpOr, "||") MakeBinOp(OpImpl, "->") MakeBinOp(OpUpdate, "//") -MakeBinOp(OpConcatStrings, "+") MakeBinOp(OpConcatLists, "++") - -#if 0 -/* Show a position. */ -string showPos(ATerm pos); +struct ExprConcatStrings : Expr +{ + vector * es; + ExprConcatStrings(vector * es) : es(es) { }; + COMMON_METHODS +}; +#if 0 /* Generic bottomup traversal over ATerms. The traversal first recursively descends into subterms, and then applies the given term function to the resulting term. */ -- cgit 1.4.1