Skip to content

pocketberserker/atto

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

atto: everyday parsers

atto is a compact, pure-functional, incremental text parsing library for Scala (if you're looking for binary parsing, please turn your attention to scodec). The atto API is non-invasive (nothing to extend!) and uses sensible and familiar abstractions. atto parsers are a fun and principled tool for everyday parsing.

scala> sepBy(int, spaceChar).parseOnly("1 20 300").option
res0: Option[List[Int]] = Some(List(1, 20, 300))

Current versions are available for Scala 2.10 and 2.11 with scalaz 7.0 and 7.1

  • For scalaz 7.0 use atto 0.3.
  • For scalaz 7.1 use atto 0.4.0.

Getting Started

Add atto as a dependency in your build.sbt file. The atto-core library is probably all you need, but if you are using Spire and want parsers for unsigned integral types you can also add atto-spire.

resolvers += "tpolecat"  at "http://dl.bintray.com/tpolecat/maven"

libraryDependencies ++= Seq(
  "org.tpolecat" %% "atto-core"  % "0.4.0", // Core parsers and combinators
  "org.tpolecat" %% "atto-spire" % "0.4.0"  // Optional, parsers for unsigned integral types
)

Experimental integration with scalaz-stream is provided by atto-stream which can be added as above. This tiny library provides combinators to turn Parser[A] into Process1[String, A] with a few variations. There is a very basic example given here.

Documentation

Behold:

  • A wee REPL tutorial. (The only change from the 0.1 version is the new import for Spire combinators).
  • A variety of tasty examples.
  • Here's the Scaladoc but it's kind of grim at the moment.
  • Read the source! Perhaps start with the parser definitions.

Contributors

The core of atto originated in @ekmett's Scala port of Attoparsec. This library is an elaboration maintained by @tpolecat with contributions from @runarorama, @marcsaegesser, and @coltfred. Feedback (complaints especially) and suggestions are always welcome.

License

Attoparsec, a Haskell library, is licensed under BSD-3 as specified here; the derivative work atto is provided under the MIT licence here. Both licenses appear in project metadata.

About

friendly little parsers

Resources

License

Stars

Watchers

Forks

Packages

No packages published