diff options
author | michelou <michelou@epfl.ch> | 2006-03-07 16:42:36 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-03-07 16:42:36 +0000 |
commit | ba72a27f4aea5bcf2f552cd596a7b72ede78d134 (patch) | |
tree | 990fb74d18413b0de47fc8d9d22d0fc304c27b18 | |
parent | 3e27d741d1e8926c6d9623d459ea1de034cd8ac4 (diff) | |
download | scala-ba72a27f4aea5bcf2f552cd596a7b72ede78d134.tar.gz scala-ba72a27f4aea5bcf2f552cd596a7b72ede78d134.tar.bz2 scala-ba72a27f4aea5bcf2f552cd596a7b72ede78d134.zip |
changed version numbering
added Ant task 'examples'
-rw-r--r-- | build.product.properties | 3 | ||||
-rw-r--r-- | build.xml | 60 | ||||
-rw-r--r-- | docs/examples/expressions/expressions-current.scala | 53 | ||||
-rw-r--r-- | docs/examples/mobile/sort.scala | 22 | ||||
-rw-r--r-- | docs/examples/parsers2.scala | 6 |
5 files changed, 99 insertions, 45 deletions
diff --git a/build.product.properties b/build.product.properties new file mode 100644 index 0000000000..b07aac33c4 --- /dev/null +++ b/build.product.properties @@ -0,0 +1,3 @@ +version.major=2 +version.minor=0 +version.patch=0
\ No newline at end of file @@ -28,12 +28,14 @@ PROPERTIES <!-- Base properties --> <property name="docs.dir" value="${basedir}/docs"/> + <property name="examples.dir" value="${docs.dir}/examples"/> <property name="lib.dir" value="${basedir}/lib"/> <property name="src.dir" value="${basedir}/src"/> <property name="test.dir" value="${basedir}/test"/> <!-- User properties --> <property file="${basedir}/build.properties"/> <!-- General properties --> + <property file="${basedir}/build.product.properties"/> <property name="copyright" value="(c) 2002-2006 LAMP/EPFL"/> <!-- NSC configuration properties --> <property name="nsc.logging" value="none"/> @@ -263,14 +265,24 @@ INITIALISATION failonerror="false" /> <propertyregex - property="revision" + property="svn.revision" input="${entries}" regexp="revision=\042([0-9]*)\042\.*" select="\1" defaultValue="x" /> - <property name="version.number" value="2.0.${revision}"/> + <!-- see http://www.xfree86.org/4.1.0/Versions2.html --> + <!-- or http://mail-index.netbsd.org/tech-kern/2004/09/30/0020.html --> + <property name="version.number" + value="${version.major}.${version.minor}.${version.patch}.${svn.revision}"/> <echo level="verbose" message="version.number=${version.number}"/> + <condition property="version.number.valid"> + <length string="${version.number}" when="greater" length="6"/> + </condition> + <fail unless="version.number.valid"> + Version number is invalid. Please check the 'version.*' properties + in file ${basedir}/build.product.properties. + </fail> <property name="dist.current.dir" value="${dist.dir}/${dist.name}-${version.number}" @@ -278,7 +290,7 @@ INITIALISATION <echo file="${nsc.timers}" append="true" - message="${line.separator}Revision ${revision};${line.separator} built ${start.human-time};${line.separator} by ${java.vm.name} ${java.vm.version};${line.separator} on ${os.name} ${os.arch} ${os.version}:" + message="${line.separator}Revision ${revision};${line.separator} built ${start.human-time};${line.separator} by ${java.vm.name} ${java.vm.version};${line.separator} on ${os.name} ${os.arch} ${os.version}:${line.separator}" /> <property name="init.avail" value="yes"/> </target> @@ -759,7 +771,7 @@ TEST </target> <!-- =========================================================================== -DOCUMENT +DOCUMENTATION ============================================================================ --> <target @@ -770,6 +782,46 @@ DOCUMENT </target> <!-- =========================================================================== +EXAMPLES +============================================================================ --> + + <target name="examples" depends="setup"> + <remove dir="${build.dir}/examples"/> + <mkdir dir="${build.dir}"/> + <pathconvert property="list" pathsep=","> + <path> + <fileset dir="${examples.dir}" includes="**/*.scala"/> + </path> + <mapper> + <globmapper from="${examples.dir}/*" to="*"/> + </mapper> + </pathconvert> + <for list="${list}" param="file"> + <sequential> + <starr srcdir="${examples.dir}" + destdir="${build.dir}"> + <classpath> + <pathelement location="${starr.lib.jar}"/> + <pathelement location="${build.dir}"/> + </classpath> + <include name="@{file}"/> + </starr> + </sequential> + </for> + <for list="${list}" param="file"> + <sequential> + <basename property="classname" file="@{file}" suffix=".scala"/> + <java classname="examples.${classname}"> + <classpath> + <pathelement location="${starr.lib.jar}"/> + <pathelement location="${build.dir}"/> + </classpath> + </java> + </sequential> + </for> + </target> + +<!-- =========================================================================== GENERATES A DISTRIBUTION ============================================================================ --> diff --git a/docs/examples/expressions/expressions-current.scala b/docs/examples/expressions/expressions-current.scala index 91e5df02ae..5eeb439430 100644 --- a/docs/examples/expressions/expressions-current.scala +++ b/docs/examples/expressions/expressions-current.scala @@ -1,67 +1,66 @@ -package examples.expressions; +package examples.expressions abstract class Lang { trait Visitor { - def caseNum(n: int): unit; + def caseNum(n: int): unit } abstract class Exp { - def visit(v: visitor): unit; + def visit(v: visitor): unit } - type visitor <: Visitor; + type visitor <: Visitor class Num(n: int) extends Exp { - def visit(v: visitor): unit = v.caseNum(n); + def visit(v: visitor): unit = v.caseNum(n) } - class Eval(result: Ref[int]): visitor extends Visitor { - def caseNum(n: int) = result.elem = n; + class Eval(result: Ref[int]) requires visitor extends Visitor { + def caseNum(n: int) = result.elem = n } } abstract class Lang2 extends Lang { abstract class Visitor2 extends Visitor { - def casePlus(left: Exp, right: Exp): unit; + def casePlus(left: Exp, right: Exp): unit } - type visitor <: Visitor2; + type visitor <: Visitor2 class Plus(l: Exp, r: Exp) extends Exp { - def visit(v: visitor): unit = v.casePlus(l, r); + def visit(v: visitor): unit = v.casePlus(l, r) } - class Eval2(result: Ref[int]): visitor extends Eval(result) with Visitor2 { + // class Eval2(result: Ref[int]): visitor extends Eval(result) with Visitor2 { + class Eval2(result: Ref[int]) requires visitor extends Visitor2 { def casePlus(l: Exp, r: Exp) = result.elem = { l.visit(this); result.elem } + { r.visit(this); result.elem } } - class Show2(result: Ref[String]): visitor extends Visitor2 { - def caseNum(n: int) = result.elem = n.toString(); + class Show2(result: Ref[String]) requires visitor extends Visitor2 { + def caseNum(n: int) = result.elem = n.toString() def casePlus(l: Exp, r: Exp) = result.elem = - "(" + { l.visit(this); result.elem } + - "+" + { r.visit(this); result.elem } + ")"; + "(" + { l.visit(this); result.elem } + + "+" + { r.visit(this); result.elem } + ")" } } object Main { - - def main(args: Array[String]) = { + def main(args: Array[String]): unit = { //val l1 = new Lang { type visitor = Visitor } // not yet implemented object l1 extends Lang { type visitor = Visitor } // workaround - val e1: l1.Exp = new l1.Num(42); - val iref = new Ref(0); - Console.println("eval: " + { e1.visit(new l1.Eval(iref)); iref.elem }); + val e1: l1.Exp = new l1.Num(42) + val iref = new Ref(0) + Console.println("eval: " + { e1.visit(new l1.Eval(iref)); iref.elem }) //val l2 = new Lang2 { type visitor = Visitor2 } // not yet implemented object l2 extends Lang2 { type visitor = Visitor2 } // workaround - val e2: l2.Exp = new l2.Plus(new l2.Num(5), new l2.Num(37)); - val sref = new Ref(""); - Console.println("eval: " + { e2.visit(new l2.Eval2(iref)); iref.elem }); - Console.println("show: " + { e2.visit(new l2.Show2(sref)); sref.elem }); - e1.visit(new l1.Eval(iref)); - e2.visit(new l2.Show2(sref)); + val e2: l2.Exp = new l2.Plus(new l2.Num(5), new l2.Num(37)) + val sref = new Ref("") + Console.println("eval: " + { e2.visit(new l2.Eval2(iref)); iref.elem }) + Console.println("show: " + { e2.visit(new l2.Show2(sref)); sref.elem }) + e1.visit(new l1.Eval(iref)) + e2.visit(new l2.Show2(sref)) } } - diff --git a/docs/examples/mobile/sort.scala b/docs/examples/mobile/sort.scala index 62818467fa..b0bfe43a54 100644 --- a/docs/examples/mobile/sort.scala +++ b/docs/examples/mobile/sort.scala @@ -1,17 +1,17 @@ -package examples.mobile; +package examples.mobile -import java.net._; -import scala.mobile._; +import java.net._ +import scala.mobile._ -object sort with Application { - val url = new URL("http://scala.epfl.ch/classes/examples.jar"); +object sort extends Application { + val url = new URL("http://scala.epfl.ch/classes/examples.jar") - val location = new Location(url); - val obj = location create "examples.sort"; - val ar = Array(6, 2, 8, 5, 1); - obj[Array[Int], Unit]("println")(ar); - obj[Array[Int], Unit]("sort")(ar); - obj[Array[Int], Unit]("println")(ar); + val location = new Location(url) + val obj = location create "examples.sort" + val ar = Array(6, 2, 8, 5, 1) + obj[Array[Int], Unit]("println")(ar) + obj[Array[Int], Unit]("sort")(ar) + obj[Array[Int], Unit]("println")(ar) Console.println } diff --git a/docs/examples/parsers2.scala b/docs/examples/parsers2.scala index a4211b3ebf..2688b162ee 100644 --- a/docs/examples/parsers2.scala +++ b/docs/examples/parsers2.scala @@ -16,13 +16,13 @@ object parsers2 { def ident: Parser[Tree] = for ( val c: char <- chr(isLetter); - val cs: List[char] <- rep(chr(d: char => Character.isLetterOrDigit(d))) + val cs: List[char] <- rep(chr(isLetterOrDigit)) ) yield Id((c :: cs).mkString("", "", "")) def number: Parser[Tree] = for ( - val d: char <- chr(c: char => Character.isDigit(c)); - val ds: List[char] <- rep(chr(c: char => Character.isDigit(c))) + val d: char <- chr(isDigit); + val ds: List[char] <- rep(chr(isDigit)) ) yield Num(((d - '0') /: ds) ((x, digit) => x * 10 + digit - '0')) def list: Parser[Tree] = |