Error : object parsing is not a member of package util

I am asking this question, since every time I try to compile a Scala class file, the compiler response is
error: object parsing is not a member of package util

I have included the dependencies as below :
libraryDependencies += "org.scala-lang.modules" %% "scala-parser-combinators" % "1.1.2"

Could anybody help me tackle this query please ?

Thanks a lot and good day,
Gianluca Zahra

The full error is :

error: object parsing is not a member of package util
import scala.util.parsing.combinator.RegexParsers
                  ^

Thanks :slight_smile:

Based on what you provided there’s no obvious reason why this shouldn’t work.

Could you give some more information such as

  • build.sbt file
  • directory structure of your project
  • command used to compile
1 Like

Build.sbt file :

scalaVersion := "2.13.4"

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

Directory :

 src/main/scala/Lexer.scala
 src/main/scala/Token.scala

Command used to compile:

scalac Token.scala
scalac Lexer.scala

Thanks a lot and good day :slight_smile:

The idea of using a build tool like sbt is to let it manage low level tools like scalac.

The moment you run scalac foo everything you added you your build.sbt is just meaningless.

Use sbt compile which will compile all the classes in your project.

2 Likes

Besides to what @BalmungSan said, you don’t need to manage the scala-library manually in sbt, it does this automatically for you.

ThisBuild / scalaVersion := "2.13.4"

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

Is all you need.

2 Likes

Thanks all.

I’ll try that and I update you with the issue.

Thanks a lot and good day