-
-
Save jrudolph/833412 to your computer and use it in GitHub Desktop.
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 wolv.parserlibproblem | |
import util.parsing.ast.AbstractSyntax | |
import util.parsing.combinator.syntactical.TokenParsers | |
import util.parsing.combinator.lexical.Lexical | |
import util.parsing.combinator.token.Tokens | |
trait SimpleTokens extends Tokens { | |
case class Foo extends Token | |
case class Bar extends Token | |
} | |
class SimpleLex extends Lexical with SimpleTokens { | |
} | |
trait SimpleAst extends AbstractSyntax { | |
sealed trait Exp extends Element | |
case class Num() extends Exp | |
case class Str() extends Exp | |
} | |
object MyModel extends SimpleAst { | |
object Parser extends TokenParsers { | |
type Tokens = SimpleLex | |
def parse = Num() | |
} | |
object PrettyPrinter { | |
def print(x: Exp) = 42 | |
} | |
} | |
class Problem extends Application { | |
val parser = MyModel.Parser | |
val prettyPrinter = MyModel.PrettyPrinter | |
println(prettyPrinter.print(parser.parse)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment