-
-
Notifications
You must be signed in to change notification settings - Fork 237
/
DummyCompilerServices.scala
30 lines (27 loc) · 1.29 KB
/
DummyCompilerServices.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// (C) Uri Wilensky. https://github.com/NetLogo/NetLogo
package org.nlogo.api
// just enough functionality to make the tests pass
class DummyCompilerServices extends CompilerServices {
private def unsupported = throw new UnsupportedOperationException
def readFromString(s: String): AnyRef =
try { s.toDouble: java.lang.Double }
catch {
case ex: NumberFormatException =>
s match {
case "true" => true: java.lang.Boolean
case "false" => false: java.lang.Boolean
case _ => throw new CompilerException(
"not a constant recognized by DummyCompilerServices", 0, s.size, "")
}
}
def autoConvert(source: String, subprogram: Boolean, reporter: Boolean, modelVersion: String) = source
def readNumberFromString(source: String) = source
def checkReporterSyntax(source: String) { }
def checkCommandSyntax(source: String) { }
def isConstant(s: String): Boolean = unsupported
def isValidIdentifier(s: String): Boolean = unsupported
def isReporter(s: String): Boolean = unsupported
def tokenizeForColorization(s: String): Array[Token] = unsupported
def getTokenAtPosition(source: String, position: Int): Token = unsupported
def findProcedurePositions(source: String): java.util.Map[String, java.util.List[AnyRef]] = unsupported
}