From 7d4567f2cc16959e827f542e6de76a28ff11789e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 11 Oct 2006 21:59:33 +0000 Subject: [PATCH] * Removed URIs from the evaluator (NIX-66). They are now just another kind of notation for strings. --- doc/manual/writing-nix-expressions.xml | 14 +++++++++----- src/libexpr/eval.cc | 4 +--- src/libexpr/expr-to-xml.cc | 3 --- src/libexpr/nixexpr-ast.def | 1 - src/libexpr/nixexpr.cc | 2 -- src/libexpr/parser.y | 4 ++-- src/libexpr/primops.cc | 3 +-- tests/lang/parse-okay-regression-20041027.exp | 2 +- tests/lang/parse-okay-subversion.exp | 2 +- tests/lang/parse-okay-url.exp | 2 +- 10 files changed, 16 insertions(+), 21 deletions(-) diff --git a/doc/manual/writing-nix-expressions.xml b/doc/manual/writing-nix-expressions.xml index e8d84164e..b8d097ae2 100644 --- a/doc/manual/writing-nix-expressions.xml +++ b/doc/manual/writing-nix-expressions.xml @@ -649,16 +649,20 @@ configureFlags = " some of which in turn contain expressions (e.g., ${mesa}). + As a convenience, URIs as defined in + appendix B of RFC 2396 + can be written as is, without quotes. For + instance, the string + "https://svn.cs.uu.nl:12443/dist/trace/trace-nix-trunk.tar.bz2" + can also be written as + https://svn.cs.uu.nl:12443/dist/trace/trace-nix-trunk.tar.bz2. + Integers, e.g., 123. - URIs as defined in appendix B - of RFC - 2396, e.g., - https://svn.cs.uu.nl:12443/dist/trace/trace-nix-trunk.tar.bz2. - Paths, e.g., /bin/sh or ./builder.sh. A path must contain at least one slash to be recognised as such; for diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc index 2d54f1fc2..4f97c761e 100644 --- a/src/libexpr/eval.cc +++ b/src/libexpr/eval.cc @@ -254,8 +254,7 @@ string coerceToStringWithContext(EvalState & state, } ATerm s; - if (matchStr(e, s) || matchUri(e, s)) - return aterm2String(s); + if (matchStr(e, s)) return aterm2String(s); if (matchPath(e, s)) { isPath = true; @@ -346,7 +345,6 @@ Expr evalExpr2(EvalState & state, Expr e) /* Normal forms. */ if (sym == symStr || sym == symPath || - sym == symUri || sym == symNull || sym == symInt || sym == symBool || diff --git a/src/libexpr/expr-to-xml.cc b/src/libexpr/expr-to-xml.cc index 085488bb5..195cbd7b8 100644 --- a/src/libexpr/expr-to-xml.cc +++ b/src/libexpr/expr-to-xml.cc @@ -36,9 +36,6 @@ static void printTermAsXML(Expr e, XMLWriter & doc, ATermList & context) else if (matchPath(e, s)) doc.writeEmptyElement("path", singletonAttrs("value", aterm2String(s))); - else if (matchUri(e, s)) - doc.writeEmptyElement("uri", singletonAttrs("value", aterm2String(s))); - else if (matchNull(e)) doc.writeEmptyElement("null"); diff --git a/src/libexpr/nixexpr-ast.def b/src/libexpr/nixexpr-ast.def index 4a92eaebf..b797fcfc4 100644 --- a/src/libexpr/nixexpr-ast.def +++ b/src/libexpr/nixexpr-ast.def @@ -26,7 +26,6 @@ Var | string | Expr | Int | int | Expr | Str | string | Expr | Path | string | Expr | -Uri | string | Expr | List | ATermList | Expr | BlackHole | | Expr | Undefined | | Expr | diff --git a/src/libexpr/nixexpr.cc b/src/libexpr/nixexpr.cc index 582eecaf7..a36b45bc1 100644 --- a/src/libexpr/nixexpr.cc +++ b/src/libexpr/nixexpr.cc @@ -301,7 +301,6 @@ string showType(Expr e) int i1; if (matchStr(e, t1)) return "a string"; if (matchPath(e, t1)) return "a path"; - if (matchUri(e, t1)) return "a path"; if (matchNull(e)) return "null"; if (matchInt(e, i1)) return "an integer"; if (matchBool(e, t1)) return "a boolean"; @@ -330,7 +329,6 @@ string showValue(Expr e) return "\"" + u + "\""; } if (matchPath(e, s)) return aterm2String(s); - if (matchUri(e, s)) return aterm2String(s); if (matchNull(e)) return "null"; if (matchInt(e, i)) return (format("%1%") % i).str(); if (e == eTrue) return "true"; diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index f5c3435e5..d13a1a133 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -3,7 +3,7 @@ %locations %error-verbose %defines -%no-lines +/* %no-lines */ %parse-param { yyscan_t scanner } %parse-param { ParseData * data } %lex-param { yyscan_t scanner } @@ -200,7 +200,7 @@ expr_simple else $$ = makeConcatStrings(ATreverse($2)); } | PATH { $$ = makePath(toATerm(absPath(aterm2String($1), data->basePath))); } - | URI { $$ = makeUri($1); } + | URI { $$ = makeStr($1); } | '(' expr ')' { $$ = $2; } /* Let expressions `let {..., body = ...}' are just desugared into `(rec {..., body = ...}).body'. */ diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc index 761677a70..f35ba737d 100644 --- a/src/libexpr/primops.cc +++ b/src/libexpr/primops.cc @@ -137,7 +137,6 @@ void toString(EvalState & state, Expr e, scripting convenience, just like `null'. */ if (matchStr(e, s)) result += aterm2String(s); - else if (matchUri(e, s)) result += aterm2String(s); else if (e == eTrue) result += "1"; else if (e == eFalse) ; else if (matchInt(e, n)) result += int2String(n); @@ -482,7 +481,7 @@ static Expr primDirOf(EvalState & state, const ATermVector & args) ATerm coerceToString(Expr e) { ATerm s; - if (matchStr(e, s) || matchPath(e, s) || matchUri(e, s)) + if (matchStr(e, s) || matchPath(e, s)) return s; return 0; } diff --git a/tests/lang/parse-okay-regression-20041027.exp b/tests/lang/parse-okay-regression-20041027.exp index 38d72aa88..8bdefdef2 100644 --- a/tests/lang/parse-okay-regression-20041027.exp +++ b/tests/lang/parse-okay-regression-20041027.exp @@ -1 +1 @@ -Function([Formal("stdenv",UnrestrictedValues,NoDefaultValue),Formal("fetchurl",UnrestrictedValues,NoDefaultValue)],Call(Select(Var("stdenv"),"mkDerivation"),Attrs([Bind("name",Str("libXi-6.0.1"),Pos("(string)",4,7)),Bind("src",Call(Var("fetchurl"),Attrs([Bind("url",Uri("http://freedesktop.org/~xlibs/release/libXi-6.0.1.tar.bz2"),Pos("(string)",6,8)),Bind("md5",Str("7e935a42428d63a387b3c048be0f2756"),Pos("(string)",7,8))])),Pos("(string)",5,6))])),Pos("(string)",1,2)) +Function([Formal("stdenv",UnrestrictedValues,NoDefaultValue),Formal("fetchurl",UnrestrictedValues,NoDefaultValue)],Call(Select(Var("stdenv"),"mkDerivation"),Attrs([Bind("name",Str("libXi-6.0.1"),Pos("(string)",4,7)),Bind("src",Call(Var("fetchurl"),Attrs([Bind("url",Str("http://freedesktop.org/~xlibs/release/libXi-6.0.1.tar.bz2"),Pos("(string)",6,8)),Bind("md5",Str("7e935a42428d63a387b3c048be0f2756"),Pos("(string)",7,8))])),Pos("(string)",5,6))])),Pos("(string)",1,2)) diff --git a/tests/lang/parse-okay-subversion.exp b/tests/lang/parse-okay-subversion.exp index 552b43259..5e6fb6e0b 100644 --- a/tests/lang/parse-okay-subversion.exp +++ b/tests/lang/parse-okay-subversion.exp @@ -1 +1 @@ -Function([Formal("localServer",UnrestrictedValues,DefaultValue(Var("false"))),Formal("httpServer",UnrestrictedValues,DefaultValue(Var("false"))),Formal("sslSupport",UnrestrictedValues,DefaultValue(Var("false"))),Formal("pythonBindings",UnrestrictedValues,DefaultValue(Var("false"))),Formal("javaSwigBindings",UnrestrictedValues,DefaultValue(Var("false"))),Formal("javahlBindings",UnrestrictedValues,DefaultValue(Var("false"))),Formal("stdenv",UnrestrictedValues,NoDefaultValue),Formal("fetchurl",UnrestrictedValues,NoDefaultValue),Formal("openssl",UnrestrictedValues,DefaultValue(Var("null"))),Formal("httpd",UnrestrictedValues,DefaultValue(Var("null"))),Formal("db4",UnrestrictedValues,DefaultValue(Var("null"))),Formal("expat",UnrestrictedValues,NoDefaultValue),Formal("swig",UnrestrictedValues,DefaultValue(Var("null"))),Formal("j2sdk",UnrestrictedValues,DefaultValue(Var("null")))],Assert(OpNEq(Var("expat"),Var("null")),Assert(OpImpl(Var("localServer"),OpNEq(Var("db4"),Var("null"))),Assert(OpImpl(Var("httpServer"),OpAnd(OpNEq(Var("httpd"),Var("null")),OpEq(Select(Var("httpd"),"expat"),Var("expat")))),Assert(OpImpl(Var("sslSupport"),OpAnd(OpNEq(Var("openssl"),Var("null")),OpImpl(Var("httpServer"),OpEq(Select(Var("httpd"),"openssl"),Var("openssl"))))),Assert(OpImpl(Var("pythonBindings"),OpAnd(OpNEq(Var("swig"),Var("null")),Select(Var("swig"),"pythonSupport"))),Assert(OpImpl(Var("javaSwigBindings"),OpAnd(OpNEq(Var("swig"),Var("null")),Select(Var("swig"),"javaSupport"))),Assert(OpImpl(Var("javahlBindings"),OpNEq(Var("j2sdk"),Var("null"))),Call(Select(Var("stdenv"),"mkDerivation"),Attrs([Bind("name",Str("subversion-1.1.1"),Pos("(string)",20,7)),Bind("builder",Path("/foo/bar"),Pos("(string)",22,10)),Bind("src",Call(Var("fetchurl"),Attrs([Bind("url",Uri("http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"),Pos("(string)",24,8)),Bind("md5",Str("a180c3fe91680389c210c99def54d9e0"),Pos("(string)",25,8))])),Pos("(string)",23,6)),Bind("patches",If(Var("javahlBindings"),List([Path("/javahl.patch")]),List([])),Pos("(string)",31,10)),Bind("openssl",If(Var("sslSupport"),Var("openssl"),Var("null")),Pos("(string)",33,10)),Bind("httpd",If(Var("httpServer"),Var("httpd"),Var("null")),Pos("(string)",34,8)),Bind("db4",If(Var("localServer"),Var("db4"),Var("null")),Pos("(string)",35,6)),Bind("swig",If(OpOr(Var("pythonBindings"),Var("javaSwigBindings")),Var("swig"),Var("null")),Pos("(string)",36,7)),Bind("python",If(Var("pythonBindings"),Select(Var("swig"),"python"),Var("null")),Pos("(string)",37,9)),Bind("j2sdk",If(Var("javaSwigBindings"),Select(Var("swig"),"j2sdk"),If(Var("javahlBindings"),Var("j2sdk"),Var("null"))),Pos("(string)",38,8)),Bind("expat",Var("expat"),Pos("(string)",41,10)),Bind("localServer",Var("localServer"),Pos("(string)",41,10)),Bind("httpServer",Var("httpServer"),Pos("(string)",41,10)),Bind("sslSupport",Var("sslSupport"),Pos("(string)",41,10)),Bind("pythonBindings",Var("pythonBindings"),Pos("(string)",41,10)),Bind("javaSwigBindings",Var("javaSwigBindings"),Pos("(string)",41,10)),Bind("javahlBindings",Var("javahlBindings"),Pos("(string)",41,10))])),Pos("(string)",17,7)),Pos("(string)",16,7)),Pos("(string)",15,7)),Pos("(string)",14,7)),Pos("(string)",13,7)),Pos("(string)",12,7)),Pos("(string)",11,7)),Pos("(string)",1,2)) +Function([Formal("localServer",UnrestrictedValues,DefaultValue(Var("false"))),Formal("httpServer",UnrestrictedValues,DefaultValue(Var("false"))),Formal("sslSupport",UnrestrictedValues,DefaultValue(Var("false"))),Formal("pythonBindings",UnrestrictedValues,DefaultValue(Var("false"))),Formal("javaSwigBindings",UnrestrictedValues,DefaultValue(Var("false"))),Formal("javahlBindings",UnrestrictedValues,DefaultValue(Var("false"))),Formal("stdenv",UnrestrictedValues,NoDefaultValue),Formal("fetchurl",UnrestrictedValues,NoDefaultValue),Formal("openssl",UnrestrictedValues,DefaultValue(Var("null"))),Formal("httpd",UnrestrictedValues,DefaultValue(Var("null"))),Formal("db4",UnrestrictedValues,DefaultValue(Var("null"))),Formal("expat",UnrestrictedValues,NoDefaultValue),Formal("swig",UnrestrictedValues,DefaultValue(Var("null"))),Formal("j2sdk",UnrestrictedValues,DefaultValue(Var("null")))],Assert(OpNEq(Var("expat"),Var("null")),Assert(OpImpl(Var("localServer"),OpNEq(Var("db4"),Var("null"))),Assert(OpImpl(Var("httpServer"),OpAnd(OpNEq(Var("httpd"),Var("null")),OpEq(Select(Var("httpd"),"expat"),Var("expat")))),Assert(OpImpl(Var("sslSupport"),OpAnd(OpNEq(Var("openssl"),Var("null")),OpImpl(Var("httpServer"),OpEq(Select(Var("httpd"),"openssl"),Var("openssl"))))),Assert(OpImpl(Var("pythonBindings"),OpAnd(OpNEq(Var("swig"),Var("null")),Select(Var("swig"),"pythonSupport"))),Assert(OpImpl(Var("javaSwigBindings"),OpAnd(OpNEq(Var("swig"),Var("null")),Select(Var("swig"),"javaSupport"))),Assert(OpImpl(Var("javahlBindings"),OpNEq(Var("j2sdk"),Var("null"))),Call(Select(Var("stdenv"),"mkDerivation"),Attrs([Bind("name",Str("subversion-1.1.1"),Pos("(string)",20,7)),Bind("builder",Path("/foo/bar"),Pos("(string)",22,10)),Bind("src",Call(Var("fetchurl"),Attrs([Bind("url",Str("http://subversion.tigris.org/tarballs/subversion-1.1.1.tar.bz2"),Pos("(string)",24,8)),Bind("md5",Str("a180c3fe91680389c210c99def54d9e0"),Pos("(string)",25,8))])),Pos("(string)",23,6)),Bind("patches",If(Var("javahlBindings"),List([Path("/javahl.patch")]),List([])),Pos("(string)",31,10)),Bind("openssl",If(Var("sslSupport"),Var("openssl"),Var("null")),Pos("(string)",33,10)),Bind("httpd",If(Var("httpServer"),Var("httpd"),Var("null")),Pos("(string)",34,8)),Bind("db4",If(Var("localServer"),Var("db4"),Var("null")),Pos("(string)",35,6)),Bind("swig",If(OpOr(Var("pythonBindings"),Var("javaSwigBindings")),Var("swig"),Var("null")),Pos("(string)",36,7)),Bind("python",If(Var("pythonBindings"),Select(Var("swig"),"python"),Var("null")),Pos("(string)",37,9)),Bind("j2sdk",If(Var("javaSwigBindings"),Select(Var("swig"),"j2sdk"),If(Var("javahlBindings"),Var("j2sdk"),Var("null"))),Pos("(string)",38,8)),Bind("expat",Var("expat"),Pos("(string)",41,10)),Bind("localServer",Var("localServer"),Pos("(string)",41,10)),Bind("httpServer",Var("httpServer"),Pos("(string)",41,10)),Bind("sslSupport",Var("sslSupport"),Pos("(string)",41,10)),Bind("pythonBindings",Var("pythonBindings"),Pos("(string)",41,10)),Bind("javaSwigBindings",Var("javaSwigBindings"),Pos("(string)",41,10)),Bind("javahlBindings",Var("javahlBindings"),Pos("(string)",41,10))])),Pos("(string)",17,7)),Pos("(string)",16,7)),Pos("(string)",15,7)),Pos("(string)",14,7)),Pos("(string)",13,7)),Pos("(string)",12,7)),Pos("(string)",11,7)),Pos("(string)",1,2)) diff --git a/tests/lang/parse-okay-url.exp b/tests/lang/parse-okay-url.exp index fa6706e21..801f14983 100644 --- a/tests/lang/parse-okay-url.exp +++ b/tests/lang/parse-okay-url.exp @@ -1 +1 @@ -List([Uri("x:x"),Uri("https://svn.cs.uu.nl:12443/repos/trace/trunk"),Uri("http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2"),Uri("http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz"),Uri("http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz"),Uri("ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz")]) +List([Str("x:x"),Str("https://svn.cs.uu.nl:12443/repos/trace/trunk"),Str("http://www2.mplayerhq.hu/MPlayer/releases/fonts/font-arial-iso-8859-1.tar.bz2"),Str("http://losser.st-lab.cs.uu.nl/~armijn/.nix/gcc-3.3.4-static-nix.tar.gz"),Str("http://fpdownload.macromedia.com/get/shockwave/flash/english/linux/7.0r25/install_flash_player_7_linux.tar.gz"),Str("ftp://ftp.gtk.org/pub/gtk/v1.2/gtk+-1.2.10.tar.gz")])