Skip to content

Merge 1.0.x to master (i.e. 1.1.x) #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 31 commits into from
May 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
6c52b6a
bump scala, sbt & scala-js dependency versions
gourlaysama Dec 16, 2016
acddd21
Merge pull request #92 from gourlaysama/bump4
SethTisue Dec 16, 2016
fbf3d08
Update latest API link, add getting started link
raboof Dec 31, 2016
33792d3
Add link to 'Building a lexer and parser with Scala's Parser Combinat…
raboof Dec 31, 2016
94e25a3
Merge pull request #93 from raboof/patch-1
gourlaysama Jan 3, 2017
c0dabd9
Update version and README for v1.0.5
gourlaysama Jan 3, 2017
0e3326f
link to Programming in Scala from README.md
SethTisue Jan 3, 2017
5d733ef
Merge pull request #94 from gourlaysama/update-post-1.0.5
gourlaysama Jan 3, 2017
04a2f50
Merge pull request #95 from SethTisue/odersky-venners-spoon
gourlaysama Jan 3, 2017
7df76d7
Add "Getting Started" section to README
raboof Jan 6, 2017
48dc032
Move 'Getting Started' guide to separate file
raboof Jan 11, 2017
f536e54
Add Getting Started example to the README
raboof Jan 11, 2017
d0d847d
Merge pull request #96 from raboof/getting_started
gourlaysama Jan 19, 2017
f1a47ee
Syntax highlight
ladinu Feb 6, 2017
cf326ad
Merge pull request #98 from ladinu/patch-1
gourlaysama Feb 6, 2017
d901210
speed up Travis builds using caching feature
gourlaysama Feb 8, 2017
5ec6af9
Merge pull request #100 from gourlaysama/travis-caching
gourlaysama Feb 8, 2017
399bbb8
Update Getting_Started.md
zandbee Feb 13, 2017
7815fd9
Deprecate scala.util.parsing.json
janekdb Feb 14, 2017
d118db9
Merge pull request #103 from janekdb/issue/github/99/deprecate-scala.…
gourlaysama Feb 14, 2017
f09b0ec
Merge pull request #102 from Zandbee/patch-1
gourlaysama Feb 15, 2017
6ca3c3d
Improve parser combinator documentation
gourlaysama Feb 20, 2017
eb5bc9a
Merge pull request #106 from gourlaysama/improve-scaladoc-output
gourlaysama Feb 22, 2017
6cac8c3
Allow building an existing tag against a new Scala version
lrytz Apr 20, 2017
26d971a
Also cross-build against 2.13.0-M1
lrytz Apr 25, 2017
0da708b
Merge pull request #109 from lrytz/tag-with-scala-version
gourlaysama Apr 28, 2017
9b705dd
Disable publishing of root project
gourlaysama May 2, 2017
65802b5
Merge pull request #112 from gourlaysama/no-root-publish
gourlaysama May 2, 2017
0982f5e
Update scala version in README and build.sbt
gourlaysama May 2, 2017
2cb29f8
Merge pull request #114 from gourlaysama/bump4
gourlaysama May 2, 2017
5a972f2
Merge branch '1.0.x' into merge-1.0.x-master
gourlaysama May 3, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ addons:
hosts:
- myshorthost
hostname: myshorthost
apt:
packages:
- graphviz

env:
global:
Expand All @@ -28,3 +31,12 @@ notifications:
email:
- [email protected]
- [email protected]

before_cache:
- find $HOME/.sbt -name "*.lock" | xargs rm
- find $HOME/.ivy2/cache -name "ivydata-*.properties" | xargs rm
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.sbt/boot
- $HOME/.sbt/launchers
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,60 @@ As of Scala 2.11, this library is a separate jar that can be omitted from Scala

## Documentation

* [Latest version](http://www.scala-lang.org/files/archive/api/2.11.x/scala-parser-combinators/)
* [Previous versions](http://scala-lang.org/documentation/api.html) (included in the API docs for the Scala library until Scala 2.11)
* [Current API](https://javadoc.io/page/org.scala-lang.modules/scala-parser-combinators_2.12/latest/scala/util/parsing/combinator/index.html)
* The [Getting Started](docs/Getting_Started.md) guide
* A more complicated example, [Building a lexer and parser with Scala's Parser Combinators](https://enear.github.io/2016/03/31/parser-combinators/)
* "Combinator Parsing", chapter 33 of [_Programming in Scala, Third Edition_](http://www.artima.com/shop/programming_in_scala), shows how to use this library to parse arithmetic expressions and JSON. The second half of the chapter examines how the library is implemented.

## Adding an SBT dependency
To depend on scala-parser-combinators in SBT, add something like this to your build.sbt:

```
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.4"
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.0.6"
```

(Assuming you're using a `scalaVersion` for which a scala-parser-combinators is published. The first 2.11 milestone for which this is true is 2.11.0-M4.)

To support multiple Scala versions, see the example in https://github.com/scala/scala-module-dependency-sample.

## Example

```scala
import scala.util.parsing.combinator._

case class WordFreq(word: String, count: Int) {
override def toString = "Word <" + word + "> " +
"occurs with frequency " + count
}

class SimpleParser extends RegexParsers {
def word: Parser[String] = """[a-z]+""".r ^^ { _.toString }
def number: Parser[Int] = """(0|[1-9]\d*)""".r ^^ { _.toInt }
def freq: Parser[WordFreq] = word ~ number ^^ { case wd ~ fr => WordFreq(wd,fr) }
}

object TestSimpleParser extends SimpleParser {
def main(args: Array[String]) = {
parse(freq, "johnny 121") match {
case Success(matched,_) => println(matched)
case Failure(msg,_) => println("FAILURE: " + msg)
case Error(msg,_) => println("ERROR: " + msg)
}
}
}
```

For a detailed unpacking of this example see
[Getting Started](docs/Getting_Started.md).

## ScalaJS support

Scala-parser-combinators directly supports scala-js 0.6+, starting with v1.0.5:

```
libraryDependencies += "org.scala-lang.modules" %%% "scala-parser-combinators" % "1.0.6"
```

## Contributing

* See the [Scala Developer Guidelines](https://github.com/scala/scala/blob/2.12.x/CONTRIBUTING.md) for general contributing guidelines
Expand Down
68 changes: 40 additions & 28 deletions admin/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
## Tag Driven Releasing

Copied from https://github.com/scala/scala-java8-compat/commit/4a6cfc97cd95227b86650410e1b632e5ff79335b.

### Background Reading

- http://docs.travis-ci.com/user/environment-variables/
Expand All @@ -14,47 +12,61 @@ To configure tag driven releases from Travis CI.

1. Generate a key pair for this repository with `./admin/genKeyPair.sh`.
Edit `.travis.yml` and `admin/build.sh` as prompted.
2. Publish the public key to https://pgp.mit.edu
3. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`.
1. Publish the public key to https://pgp.mit.edu
1. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`.
Edit `.travis.yml` as prompted.
4. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
1. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
and edit that script to use the tasks required for this project.
5. Edit `build.sbt` to select which JDK will be used for publishing.
1. Edit `build.sbt`'s `scalaVersionsByJvm in ThisBuild` to select Scala and JVM version
combinations that will be used for publishing.

It is important to add comments in .travis.yml to identify the name
It is important to add comments in `.travis.yml` to identify the name
of each environment variable encoded in a `:secure` section.

After all of these steps, your .travis.yml should contain config of the
form:
After these steps, your `.travis.yml` should contain config of the form:

```
language: scala

env:
global:
# PGP_PASSPHRASE
- secure: "XXXXXX"
# SONA_USER
- secure: "XXXXXX"
# SONA_PASS
- secure: "XXXXXX"

script: admin/build.sh

language: scala
env:
global:
# PGP_PASSPHRASE
- secure: "XXXXXX"
# SONA_USER
- secure: "XXXXXX"
# SONA_PASS
- secure: "XXXXXX"
script: admin/build.sh
jdk:
- openjdk6
- oraclejdk8

notifications:
email:
- [email protected]
```

If Sonatype credentials change in the future, step 3 can be repeated
without generating a new key.

Be sure to use SBT 0.13.7 or higher to avoid [#1430](https://github.com/sbt/sbt/issues/1430)!

### Testing

1. Follow the release process below to create a dummy release (e.g. 0.1.0-TEST1).
1. Follow the release process below to create a dummy release (e.g., `v0.1.0-TEST1`).
Confirm that the release was staged to Sonatype but do not release it to Maven
central. Instead, drop the staging repository.

### Performing a release

1. Create a GitHub "Release" (with a corresponding tag) via the GitHub
1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub
web interface.
2. Travis CI will schedule a build for this release. Review the build logs.
3. Log into https://oss.sonatype.org/ and identify the staging repository.
4. Sanity check its contents
5. Release staging repository to Maven and send out release announcement.

1. The release will be published using the Scala and JVM version combinations specified
in `scalaVersionsByJvm` in `build.sbt`.
- If you need to release against a different Scala version, include the Scala version
and the JVM version to use in the tag name, separated by `#`s (e.g., `v0.1.1#2.13.0-M1#8`).
Note that the JVM version needs to be listed in `.travis.yml` for the build to run.
1. Travis CI will schedule a build for this release. Review the build logs.
1. Log into https://oss.sonatype.org/ and identify the staging repository.
1. Sanity check its contents.
1. Release staging repository to Maven and send out release announcement.
44 changes: 36 additions & 8 deletions admin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,43 @@

set -e

# prep environment for publish to sonatype staging if the HEAD commit is tagged
# Builds of tagged revisions are published to sonatype staging.

# git on travis does not fetch tags, but we have TRAVIS_TAG
# headTag=$(git describe --exact-match ||:)
# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice.
# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds.
# Checking the local git clone would not work because git on travis does not fetch tags.

# The version number to be published is extracted from the tag, e.g., v1.2.3 publishes
# version 1.2.3 using all Scala versions in build.sbt's `crossScalaVersions`.

# When a new, binary incompatible Scala version becomes available, a previously released version
# can be released using that new Scala version by creating a new tag containing the Scala and the
# JVM version after hashes, e.g., v1.2.3#2.13.0-M1#8. The JVM version needs to be listed in
# `.travis.yml`, otherwise the required build doesn't run.

verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
tagPat="^v$verPat(#$verPat#[0-9]+)?$"

if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')

tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//)
publishVersion='set every version := "'$tagVer'"'

scalaAndJvmVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
if [ "$scalaAndJvmVer" != "" ]; then
scalaVer=$(echo $scalaAndJvmVer | sed s/#.*//)
jvmVer=$(echo $scalaAndJvmVer | sed s/[^#]*// | sed s/^#//)
if [ "$jvmVer" != "$currentJvmVer" ]; then
echo "Not publishing $TRAVIS_TAG on Java version $currentJvmVer."
exit 0
fi
publishScalaVersion='set every ScalaModulePlugin.scalaVersionsByJvm := Map('$jvmVer' -> List("'$scalaVer'" -> true))'
echo "Releasing $tagVer using Scala $scalaVer on Java version $jvmVer."
else
echo "Releasing $tagVer on Java version $currentJvmVer according to 'scalaVersionsByJvm' in build.sbt."
fi

if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then
echo "Going to release from tag $TRAVIS_TAG!"
myVer=$(echo $TRAVIS_TAG | sed -e s/^v//)
publishVersion='set every version := "'$myVer'"'
extraTarget="+publish-signed"
cat admin/gpg.sbt >> project/plugins.sbt
cp admin/publish-settings.sbt .
Expand All @@ -22,4 +50,4 @@ if [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
fi

sbt "$publishVersion" clean update +test +publishLocal $extraTarget
sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget
57 changes: 30 additions & 27 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,29 +1,39 @@
scalaVersion in ThisBuild := crossScalaVersions.value.head
import ScalaModulePlugin._

crossScalaVersions in ThisBuild := {
val v211 = List("2.11.8")
val v212 = List("2.12.0-RC1")
scalaVersionsByJvm in ThisBuild := {
val v211 = "2.11.11"
val v212 = "2.12.2"
val v213 = "2.13.0-M1"

val javaVersion = System.getProperty("java.version")
val isTravisPublishing = !util.Properties.envOrElse("TRAVIS_TAG", "").trim.isEmpty

if (isTravisPublishing) {
if (javaVersion.startsWith("1.6.")) v211
else if (javaVersion.startsWith("1.8.")) v212
else Nil
} else if (javaVersion.startsWith("1.6.") || javaVersion.startsWith("1.7.")) {
v211
} else if (javaVersion.startsWith("1.8.") || javaVersion.startsWith("9")) {
v211 ++ v212
} else {
sys.error(s"Unsupported java version: $javaVersion.")
}
Map(
6 -> List(v211 -> true),
7 -> List(v211 -> false),
8 -> List(v212 -> true, v213 -> true, v211 -> false),
9 -> List(v212 -> false, v213 -> false, v211 -> false)
)
}

lazy val root = project.in(file("."))
.aggregate(`scala-parser-combinatorsJS`, `scala-parser-combinatorsJVM`)
.settings(disablePublishing)

lazy val `scala-parser-combinators` = crossProject.in(file(".")).
settings(scalaModuleSettings: _*).
settings(
name := "scala-parser-combinators-root"
name := "scala-parser-combinators-root",
apiMappings += (scalaInstance.value.libraryJar ->
url(s"https://www.scala-lang.org/api/${scalaVersion.value}/")),
scalacOptions in (Compile, doc) ++= Seq(
"-diagrams",
"-doc-source-url",
s"https://github.com/scala/scala-parser-combinators/tree/v${version.value}€{FILE_PATH}.scala",
"-sourcepath",
(baseDirectory in LocalRootProject).value.absolutePath,
"-doc-title",
"Scala Parser Combinators",
"-doc-version",
version.value
)
).
jvmSettings(
// Mima uses the name of the jvm project in the artifactId
Expand All @@ -38,14 +48,7 @@ lazy val `scala-parser-combinators` = crossProject.in(file(".")).
version := "1.1.0-SNAPSHOT"
).
jvmSettings(
// important!! must come here (why?)
scalaModuleOsgiSettings: _*
).
jvmSettings(
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}"),

// needed to fix classloader issues (see scala-xml#20)
fork in Test := true
OsgiKeys.exportPackage := Seq(s"scala.util.parsing.*;version=${version.value}")
).
jsSettings(
// Scala.js cannot run forked tests
Expand Down
Loading