Refactor retrieving DataType's name
This commit is contained in:
@@ -14,6 +14,6 @@ data class Token(val type: TokenType, val value: Any, val rawValue: String, val
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "(${type.name.toLowerCase()}, »${rawValue}«, ${position.short()})"
|
||||
return "($type, »$rawValue«, ${position.short})"
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
package io.smnp.dsl.token.model.entity
|
||||
|
||||
data class TokenPosition(val line: Int, val beginCol: Int, val endCol: Int) {
|
||||
companion object {
|
||||
val NONE = TokenPosition(-1, -1, -1)
|
||||
}
|
||||
companion object {
|
||||
val NONE = TokenPosition(-1, -1, -1)
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "[line ${line+1}, col ${beginCol+1}]"
|
||||
}
|
||||
override fun toString(): String {
|
||||
return "[line ${line + 1}, col ${beginCol + 1}]"
|
||||
}
|
||||
|
||||
fun short(): String {
|
||||
return "${line+1}:${beginCol+1}"
|
||||
}
|
||||
val short: String
|
||||
get() = "${line + 1}:${beginCol + 1}"
|
||||
}
|
||||
@@ -46,5 +46,9 @@ enum class TokenType(val token: String) {
|
||||
IF("if"),
|
||||
AS("as"),
|
||||
IDENTIFIER("identifier"),
|
||||
COMMENT("comment")
|
||||
COMMENT("comment");
|
||||
|
||||
override fun toString(): String {
|
||||
return super.name.toLowerCase()
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ class AccessOperatorEvaluator : Evaluator() {
|
||||
EvaluatorOutput.value(
|
||||
lhs.properties[rhs] ?: throw PositionException(
|
||||
EnvironmentException(
|
||||
EvaluationException("Unknown property $rhs of type ${lhs.type.name.toLowerCase()}"),
|
||||
EvaluationException("Unknown property $rhs of type ${lhs.typeName}"),
|
||||
environment
|
||||
),
|
||||
rhsNode.position
|
||||
|
||||
@@ -31,7 +31,7 @@ class LoopEvaluator : Evaluator() {
|
||||
else -> throw PositionException(
|
||||
EnvironmentException(
|
||||
EvaluationException(
|
||||
"Expected for-loop with int iterator or foreach-loop with string, list or map iterator or while-loop with bool iterator, found ${iterator.type.name.toLowerCase()}"
|
||||
"Expected for-loop with int iterator or foreach-loop with string, list or map iterator or while-loop with bool iterator, found ${iterator.typeName}"
|
||||
),
|
||||
environment
|
||||
), iteratorNode.position
|
||||
|
||||
@@ -35,7 +35,7 @@ class MapEvaluator : Evaluator() {
|
||||
if (key.type !in listOf(BOOL, INT, NOTE, STRING)) {
|
||||
throw PositionException(
|
||||
EnvironmentException(
|
||||
EvaluationException("Invalid map key's type ${key.type.name.toLowerCase()}"),
|
||||
EvaluationException("Invalid map key's type ${key.typeName}"),
|
||||
environment
|
||||
),
|
||||
keyNode.position
|
||||
|
||||
@@ -26,7 +26,7 @@ class MinusOperatorEvaluator : Evaluator() {
|
||||
DataType.LIST -> Value.list((operand.value.value as List<Value>).reversed())
|
||||
else -> throw PositionException(
|
||||
EnvironmentException(
|
||||
EvaluationException("Type ${operand.value.type.name.toLowerCase()} does not support minus operator"),
|
||||
EvaluationException("Type ${operand.value.typeName} does not support minus operator"),
|
||||
environment
|
||||
),
|
||||
node.position
|
||||
|
||||
@@ -43,7 +43,7 @@ class SumOperatorEvaluator : Evaluator() {
|
||||
else throw PositionException(
|
||||
EnvironmentException(
|
||||
EvaluationException(
|
||||
"The ${lhs.type.name.toLowerCase()} and ${rhs.type.name.toLowerCase()} are not supported by + operator"
|
||||
"The ${lhs.typeName} and ${rhs.typeName} are not supported by + operator"
|
||||
),
|
||||
environment
|
||||
), plusNode.position
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.smnp.type.model.Value
|
||||
class EvaluatorOutput private constructor(val result: EvaluationResult, val value: Value?) {
|
||||
|
||||
override fun toString(): String {
|
||||
return "${result.name.toLowerCase()}(${value ?: ""})"
|
||||
return "$result(${value ?: ""})"
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
Reference in New Issue
Block a user