diff options
-rw-r--r-- | src/fix-ng/eval.cc | 7 | ||||
-rw-r--r-- | src/fix-ng/fix.sdf | 12 | ||||
-rw-r--r-- | src/fix-ng/parser.cc | 6 | ||||
-rw-r--r-- | src/fix-ng/primops.cc | 4 |
4 files changed, 24 insertions, 5 deletions
diff --git a/src/fix-ng/eval.cc b/src/fix-ng/eval.cc index 38a1d81fc..726bc5dae 100644 --- a/src/fix-ng/eval.cc +++ b/src/fix-ng/eval.cc @@ -109,8 +109,8 @@ Path evalPath(EvalState & state, Expr e) bool evalBool(EvalState & state, Expr e) { e = evalExpr(state, e); - if (ATmatch(e, "True")) return true; - else if (ATmatch(e, "False")) return false; + if (ATmatch(e, "Bool(True)")) return true; + else if (ATmatch(e, "Bool(False)")) return false; else throw badTerm("expecting a boolean", e); } @@ -124,6 +124,7 @@ Expr evalExpr2(EvalState & state, Expr e) if (ATmatch(e, "Str(<str>)", &s1) || ATmatch(e, "Path(<str>)", &s1) || ATmatch(e, "Uri(<str>)", &s1) || + ATmatch(e, "Bool(<term>)", &e1) || ATmatch(e, "Function([<list>], <term>)", &e1, &e2) || ATmatch(e, "Attrs([<list>])", &e1) || ATmatch(e, "List([<list>])", &e1)) @@ -188,7 +189,7 @@ Expr evalExpr2(EvalState & state, Expr e) if (ATmatch(e, "OpEq(<term>, <term>)", &e1, &e2)) { string s1 = evalString(state, e1); string s2 = evalString(state, e2); - return s1 == s2 ? ATmake("True") : ATmake("False"); + return s1 == s2 ? ATmake("Bool(True)") : ATmake("Bool(False)"); } /* Barf. */ diff --git a/src/fix-ng/fix.sdf b/src/fix-ng/fix.sdf index 251a63f0c..8effe6d21 100644 --- a/src/fix-ng/fix.sdf +++ b/src/fix-ng/fix.sdf @@ -68,6 +68,9 @@ exports Expr "==" Expr -> Expr {cons("OpEq")} + Bool + -> Expr {cons("Bool")} + context-free priorities Expr "." Id -> Expr @@ -84,10 +87,19 @@ exports lexical syntax [a-zA-Z\_][a-zA-Z0-9\_\']* -> Id "rec" -> Id {reject} + "true" -> Id {reject} + "false" -> Id {reject} + [0-9]+ -> Int + "\"" ~[\n\"]* "\"" -> Str + PathComp ("/" PathComp)+ -> Path [a-zA-Z0-9\.\_\-]+ -> PathComp + + "true" -> Bool + "false" -> Bool + lexical restrictions Id -/- [a-zA-Z0-9\_\'] Int -/- [0-9] diff --git a/src/fix-ng/parser.cc b/src/fix-ng/parser.cc index d310397c2..7dff0363d 100644 --- a/src/fix-ng/parser.cc +++ b/src/fix-ng/parser.cc @@ -50,6 +50,12 @@ struct Cleanup : TermFun return ATmake("Int(<int>)", n); } + if (ATmatch(e, "Bool(\"true\")", &s)) + return ATmake("Bool(True)"); + + if (ATmatch(e, "Bool(\"false\")", &s)) + return ATmake("Bool(False)"); + return e; } }; diff --git a/src/fix-ng/primops.cc b/src/fix-ng/primops.cc index 7d060124b..f887d265f 100644 --- a/src/fix-ng/primops.cc +++ b/src/fix-ng/primops.cc @@ -84,8 +84,8 @@ static string processBinding(EvalState & state, Expr e, NixExpr & ne) if (ATmatch(e, "Str(<str>)", &s)) return s; if (ATmatch(e, "Uri(<str>)", &s)) return s; - if (ATmatch(e, "True")) return "1"; - if (ATmatch(e, "False")) return ""; + if (ATmatch(e, "Bool(True)")) return "1"; + if (ATmatch(e, "Bool(False)")) return ""; if (ATmatch(e, "Attrs([<list>])", &es)) { Expr a = queryAttr(e, "type"); |