scala-parser-combinators


License

License

Categories

Categories

Scala Languages Native Development Tools
GroupId

GroupId

org.scala-lang.modules
ArtifactId

ArtifactId

scala-parser-combinators_native0.3_2.11
Last Version

Last Version

1.2.0-M1
Release Date

Release Date

Type

Type

jar
Description

Description

scala-parser-combinators
scala-parser-combinators
Project URL

Project URL

http://www.scala-lang.org/
Project Organization

Project Organization

org.scala-lang.modules
Source Code Management

Source Code Management

https://github.com/scala/scala-parser-combinators

Download scala-parser-combinators_native0.3_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/org.scala-lang.modules/scala-parser-combinators_native0.3_2.11/ -->
<dependency>
    <groupId>org.scala-lang.modules</groupId>
    <artifactId>scala-parser-combinators_native0.3_2.11</artifactId>
    <version>1.2.0-M1</version>
</dependency>
// https://jarcasting.com/artifacts/org.scala-lang.modules/scala-parser-combinators_native0.3_2.11/
implementation 'org.scala-lang.modules:scala-parser-combinators_native0.3_2.11:1.2.0-M1'
// https://jarcasting.com/artifacts/org.scala-lang.modules/scala-parser-combinators_native0.3_2.11/
implementation ("org.scala-lang.modules:scala-parser-combinators_native0.3_2.11:1.2.0-M1")
'org.scala-lang.modules:scala-parser-combinators_native0.3_2.11:jar:1.2.0-M1'
<dependency org="org.scala-lang.modules" name="scala-parser-combinators_native0.3_2.11" rev="1.2.0-M1">
  <artifact name="scala-parser-combinators_native0.3_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.scala-lang.modules', module='scala-parser-combinators_native0.3_2.11', version='1.2.0-M1')
)
libraryDependencies += "org.scala-lang.modules" % "scala-parser-combinators_native0.3_2.11" % "1.2.0-M1"
[org.scala-lang.modules/scala-parser-combinators_native0.3_2.11 "1.2.0-M1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.scala-native : nativelib_native0.3_2.11 jar 0.3.9
org.scala-native : javalib_native0.3_2.11 jar 0.3.9
org.scala-native : auxlib_native0.3_2.11 jar 0.3.9
org.scala-native : scalalib_native0.3_2.11 jar 0.3.9

test (4)

Group / Artifact Type Version
org.scala-native : test-interface_native0.3_2.11 jar 0.3.9
junit : junit jar 4.13.1
com.novocode : junit-interface jar 0.11
org.scala-lang.modules : scala-collection-compat_2.11 jar 2.3.2

Project Modules

There are no modules declared in this project.

scala-parser-combinators

Scala Standard Parser Combinator Library

This library was originally part of the Scala standard library, but is now community-maintained, under the guidance of the Scala team at Lightbend. If you are interested in helping please contact @Philippus or @SethTisue.

The latest stable release is 1.1.2.

Experimental milestone 1.2.x milestones are available. Since 1.2.0-M1, Scala 3 is supported.

Documentation

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.1.2"

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

Scala.js and Scala Native

Scala-parser-combinators is also available for Scala.js and Scala Native:

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

Example

import scala.util.parsing.combinator._

case class WordFreq(word: String, count: Int) {
  override def toString = s"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(s"FAILURE: $msg")
      case Error(msg,_) => println(s"ERROR: $msg")
    }
  }
}

For a detailed unpacking of this example see Getting Started.

Contributing

Alternatives

A number of other parsing libraries for Scala are available; see https://github.com/lauris/awesome-scala#parsing

org.scala-lang.modules

The Scala Programming Language

Versions

Version
1.2.0-M1
1.1.2