Created
July 18, 2011 17:31
-
-
Save anonymous/1090116 to your computer and use it in GitHub Desktop.
parboiled cached actions?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package lp.windhaml | |
import org.parboiled.scala._ | |
import org.parboiled.support._ | |
import org.parboiled.support.ParseTreeUtils | |
import scala.io.Source | |
class MyParser extends Parser { | |
var count = 1 | |
def all = rule { | |
oneOrMore(myrule) | |
} | |
def myrule = rule { | |
count += 1 | |
println("************ myrule: " + count) | |
drule(count, "a") | |
} | |
private def drule(count: Int, str: String) = { | |
println("############## count: " + count + ", str: " + str) | |
nTimes(count, str) | |
} | |
} | |
object MyParser { | |
def main(args: Array[String]) { | |
val parser = new MyParser { override val buildParseTree = true } | |
val fixed = "aaaaaaaaaaa" | |
val result = TracingParseRunner(parser.all).run(fixed) | |
println(result.result) | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment