This file contains hidden or 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
object Interpreter { | |
def main(args:Array[String]) = { | |
(new SimpleParser).parseString("2*3.2 + 3*(36.07/4 - 10)").println | |
} | |
import scala.util.parsing.combinator._ | |
class SimpleParser extends JavaTokenParsers { | |
def expr: Parser[Double] = ( | |
term~"+"~expr ^^ { case a~"+"~b => a + b } | |
| term~"-"~expr ^^ { case a~"-"~b => a - b } |
This file contains hidden or 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
import scala.tools.nsc.interactive.{Global, RefinedBuildManager} | |
import scala.tools.nsc.Settings | |
import scala.tools.nsc.reporters.StoreReporter | |
import scala.tools.nsc.io._ | |
import scala.tools.nsc.util._ | |
import scala.tools.nsc.interactive.Response | |
import scala.tools.nsc.util.{Position, OffsetPosition} | |
import scala.reflect.generic.Trees | |
val settings = new Settings |
NewerOlder