com-lihaoyi / fastparse

Writing Fast Parsers Fast in Scala
https://com-lihaoyi.github.io/fastparse
MIT License
1.09k stars 164 forks source link

Weird errors trying to start using fastparse #86

Closed freinn closed 8 years ago

freinn commented 8 years ago

Hi!

I'm very newbie to Scala and a total newbie using fastparse.

I've created a very simple SBT project and tried to compile and run some simple parsers from the web examples, but I get a lot of compilation errors on sbt like this:

[error] /home/freinn/parsertests/src/main/scala/Main.scala:30: No implicit view available from String => fastparse.core.Parser[V]. [error] val ab = P( "a".rep ~ "b" ) [error] ^ [error] one error found error Compilation failed

Or another one:

[error] /home/freinn/tecsisaDSL/src/main/scala/Main.scala:22: value ~ is not a member of String [error] val ab = P("a" ~ "b") [error] ^ [error] /home/freinn/tecsisaDSL/src/main/scala/Main.scala:41: too many arguments for method println: (x: Any)Unit [error] println(ParserSet.val1, ParserSet.val2) [error] ^ [error] two errors found

I'm using 0.3.7 with the following line on build.sbt:

libraryDependencies += "com.lihaoyi" %% "fastparse" % "0.3.7"

I did the import (import fastparse.all._) in the beginning of my file and created an object ParserSet { ... } with all the copied/pasted code from the web examples.

lihaoyi commented 8 years ago

Probably the same as https://github.com/lihaoyi/fastparse/issues/72, upgrading to scalaVersion := "2.11.8" should make it go away i think...

rvazquezglez commented 1 year ago

I was getting the value ~ is not a member of String error using Scala 2.13. I could work around it by surrounding the first string with P(). So instead of:

val ab = P("a" ~ "b")

I have:

val ab = P(P("a") ~ "b")

And regarding the other error No implicit view available from, it went away after using import fastparse.NoWhitespace._

lihaoyi commented 1 year ago

you are probably missing import fastparse._