Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run() can't be called on generic Rule #124

Open
kiritsuku opened this issue Dec 29, 2014 · 5 comments
Open

run() can't be called on generic Rule #124

kiritsuku opened this issue Dec 29, 2014 · 5 comments

Comments

@kiritsuku
Copy link

  import org.parboiled2._
  def parse[P <: Parser, A](p: P)(f: P => Rule1[A]) = f(p).run()

Error message in macro expansion:

Illegal .run() call base: f.apply(p)
@kiritsuku
Copy link
Author

It is also not possible to call the implicit conversion manually.

Rule.Runnable(p.program).run()

shows:

Illegal Runnable.apply call: org.parboiled2.Rule.Runnable[...](p.program)

@lihaoyi
Copy link

lihaoyi commented Dec 29, 2014

This is basically the same problem as #120: the macros are trying to be clever and falling flat on their faces

@sirthias
Copy link
Owner

sirthias commented Jan 2, 2015

Yes. We'll get this fixed with an entirely new parser and rule design.

@kiritsuku
Copy link
Author

I got it working by using p.__run(f(p)) instead of f(p).run().

@shawjef3
Copy link

shawjef3 commented Oct 8, 2015

@sschaef thanks for the work-around. I ran into this problem not with a generic rule, but a rule with two arguments.

import org.parboiled2._

class P(val input: ParserInput) extends org.parboiled2.Parser {

  def SomeRule(arg0: Int, arg1: Int): Rule0 = rule {
    str("")
  }

}

object P {
  val p = new P("")
  p.SomeRule(0, 1).run()
}
Error:(15, 13) Illegal `.run()` call base: P.this.p.SomeRule(0, 1)
  p.SomeRule(0, 1).run()
            ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants