djspiewak / parseback

A Scala implementation of parsing with derivatives
http://parseback.io
Apache License 2.0
197 stars 22 forks source link

Is the current version consistent with the intro example ? #39

Open tizuck opened 6 years ago

tizuck commented 6 years ago

Hi,

I am new to parseback and this could be completly me running against a wall, but I am having trouble getting your example of the arithmetic expression grammar to work. This line here,

val result: Eval[Either[List[ParseError], List[Int]]] = expr(input)

gives me the following Error message:

Error:(28, 63) type mismatch; found : cats.Eval[List[parseback.ParseError] \/ parseback.util.Catenable[Int]] (which expands to) cats.Eval[scala.util.Either[List[parseback.ParseError],parseback.util.Catenable[Int]]] required: cats.Eval[Either[List[parseback.ParseError],List[Int]]] val result: Eval[Either[List[ParseError], List[Int]]] = expr(input)

However, the example executes when omitting the explicit type declaration of variable result. But it will fail to parse and throw the following error message:

Left(List(UnexpectedCharacter(Line(1 + 2,0,0),Set(\s+))))

Moreover when inserting a whitespace before the 1 in the LineStream like this " 1 + 2" the example parses correctly. Am i doing anything wrong?

And also, is there a forum for questions like this? I wasn't able to find any, so i posted it here. Please let me know.

Cheers

Besides, here is my SBT File :

version := "0.1" scalaVersion := "2.12.7" resolvers += "bintray-djspiewak-maven" at "https://dl.bintray.com/djspiewak/maven" val ParsebackVersion = "0.3" libraryDependencies += "com.codecommit" %% "parseback-core" % ParsebackVersion libraryDependencies += "com.codecommit" %% "parseback-cats" % ParsebackVersion

tizuck commented 6 years ago

After observing your own test-cases in the parseback-test folder I figured, that the Whitespace is implemented in a different way. There, it is defined as

implicit val W = Whitespace(() | """\s+""".r)

which indeed does work an makes more sense. Please consider to adjust this in the intro-example.

Cheers