Skip to content

Commit 151ef0d

Browse files
authored
Merge pull request #83 from gourlaysama/backports1
[backport] Scala.js support for 1.0.x
2 parents 6582a95 + ad63597 commit 151ef0d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+89
-36
lines changed

build.sbt

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import com.typesafe.tools.mima.plugin.{MimaPlugin, MimaKeys}
2-
3-
scalaModuleSettings
4-
5-
name := "scala-parser-combinators"
6-
7-
version := "1.0.5-SNAPSHOT"
1+
scalaVersion in ThisBuild := crossScalaVersions.value.head
82

93
crossScalaVersions in ThisBuild := {
104
val javaVersion = System.getProperty("java.version")
@@ -16,16 +10,45 @@ crossScalaVersions in ThisBuild := {
1610
Seq("2.11.7", "2.12.0-M3")
1711
}
1812

19-
// important!! must come here (why?)
20-
scalaModuleOsgiSettings
21-
22-
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}")
23-
24-
// needed to fix classloader issues (see scala-xml#20)
25-
fork in Test := true
26-
27-
libraryDependencies += "junit" % "junit" % "4.11" % "test"
28-
29-
libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test"
30-
31-
mimaPreviousVersion := Some("1.0.2")
13+
lazy val `scala-parser-combinators` = crossProject.in(file(".")).
14+
settings(scalaModuleSettings: _*).
15+
settings(
16+
name := "scala-parser-combinators-root"
17+
).
18+
jvmSettings(
19+
// Mima uses the name of the jvm project in the artifactId
20+
// when resolving previous versions (so no "-jvm" project)
21+
name := "scala-parser-combinators"
22+
).
23+
jsSettings(
24+
name := "scala-parser-combinators-js"
25+
).
26+
settings(
27+
moduleName := "scala-parser-combinators",
28+
version := "1.0.5-SNAPSHOT"
29+
).
30+
jvmSettings(
31+
// important!! must come here (why?)
32+
scalaModuleOsgiSettings: _*
33+
).
34+
jvmSettings(
35+
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"),
36+
37+
// needed to fix classloader issues (see scala-xml#20)
38+
fork in Test := true
39+
).
40+
jsSettings(
41+
// Scala.js cannot run forked tests
42+
fork in Test := false
43+
).
44+
jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin)).
45+
jvmSettings(
46+
libraryDependencies += "junit" % "junit" % "4.11" % "test",
47+
libraryDependencies += "com.novocode" % "junit-interface" % "0.10" % "test"
48+
).
49+
jvmSettings(
50+
mimaPreviousVersion := Some("1.0.4")
51+
)
52+
53+
lazy val `scala-parser-combinatorsJVM` = `scala-parser-combinators`.jvm
54+
lazy val `scala-parser-combinatorsJS` = `scala-parser-combinators`.js
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package scala.util.parsing.input
2+
3+
import java.lang.CharSequence
4+
import java.util.{AbstractMap, Collections}
5+
6+
private[input] trait PositionCache {
7+
private[input] lazy val indexCache: java.util.Map[CharSequence,Array[Int]] = new AbstractMap[CharSequence, Array[Int]] {
8+
9+
override def entrySet() = Collections.emptySet()
10+
11+
// the /dev/null of Maps
12+
override def put(ch: CharSequence, a: Array[Int]) = null
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package scala.util.parsing.input
2+
3+
import java.lang.{CharSequence, ThreadLocal}
4+
import java.util.WeakHashMap
5+
6+
/**
7+
* @author Tomáš Janoušek
8+
*/
9+
private[input] trait PositionCache {
10+
private lazy val indexCacheTL =
11+
// not DynamicVariable as that would share the map from parent to child :-(
12+
new ThreadLocal[java.util.Map[CharSequence, Array[Int]]] {
13+
override def initialValue = new WeakHashMap[CharSequence, Array[Int]]
14+
}
15+
16+
private[input] def indexCache = indexCacheTL.get
17+
}

project/plugins.sbt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.4")
2+
3+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.6")

src/main/scala/scala/util/parsing/combinator/JavaTokenParsers.scala renamed to shared/src/main/scala/scala/util/parsing/combinator/JavaTokenParsers.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ trait JavaTokenParsers extends RegexParsers {
2626
* <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.8">The Java Language Spec</a>.
2727
* Generally, this means a letter, followed by zero or more letters or numbers.
2828
*/
29-
def ident: Parser[String] =
30-
"""\p{javaJavaIdentifierStart}\p{javaJavaIdentifierPart}*""".r
29+
def ident: Parser[String] = (
30+
"" ~> // handle whitespace
31+
rep1(acceptIf(Character.isJavaIdentifierStart)("identifier expected but `" + _ + "' found"),
32+
elem("identifier part", Character.isJavaIdentifierPart(_: Char))) ^^ (_.mkString)
33+
)
34+
3135
/** An integer, without sign or with a negative sign. */
3236
def wholeNumber: Parser[String] =
3337
"""-?\d+""".r
@@ -49,7 +53,7 @@ trait JavaTokenParsers extends RegexParsers {
4953
*/
5054
@migration("`stringLiteral` allows escaping single and double quotes, but not forward slashes any longer.", "2.10.0")
5155
def stringLiteral: Parser[String] =
52-
("\""+"""([^"\p{Cntrl}\\]|\\[\\'"bfnrt]|\\u[a-fA-F0-9]{4})*+"""+"\"").r
56+
("\""+"""([^"\x00-\x1F\x7F\\]|\\[\\'"bfnrt]|\\u[a-fA-F0-9]{4})*"""+"\"").r
5357
/** A number following the rules of `decimalNumber`, with the following
5458
* optional additions:
5559
*

0 commit comments

Comments
 (0)