diff --git a/src/main/kotlin/org/jetbrains/research/libsl/visitors/ExpressionVisitor.kt b/src/main/kotlin/org/jetbrains/research/libsl/visitors/ExpressionVisitor.kt index 40d9086c..c3980ca3 100644 --- a/src/main/kotlin/org/jetbrains/research/libsl/visitors/ExpressionVisitor.kt +++ b/src/main/kotlin/org/jetbrains/research/libsl/visitors/ExpressionVisitor.kt @@ -277,14 +277,15 @@ class ExpressionVisitor( } fun convertBinHexOctToPrimitives(num: String, type: String): Number { + val isInt = "i".equals(type) val result: Number = if (num.startsWith(HEX_PREFIX)) { - if ("i".equals(type)) parseInt(num.drop(2), 16) else parseLong(num.drop(2), 16) + if (isInt) parseInt(num.drop(2), 16) else parseLong(num.drop(2), 16) } else if (num.startsWith(BIN_PREFIX)) { - if ("i".equals(type)) parseInt(num.drop(2), 2) else parseLong(num.drop(2), 2) + if (isInt) parseInt(num.drop(2), 2) else parseLong(num.drop(2), 2) } else if (num.startsWith(OCT_PREFIX) && num.length > 1) { - if ("i".equals(type)) parseInt(num.drop(1), 8) else parseLong(num.drop(1), 8) + if (isInt) parseInt(num.drop(1), 8) else parseLong(num.drop(1), 8) } else { - if ("i".equals(type)) num.toInt() else num.toLong() + if (isInt) num.toInt() else num.toLong() } return result; } diff --git a/src/test/testdata/expected/lsl/charLiterals.lsl b/src/test/testdata/expected/lsl/charLiterals.lsl index ff5ac7b0..52cfb081 100644 --- a/src/test/testdata/expected/lsl/charLiterals.lsl +++ b/src/test/testdata/expected/lsl/charLiterals.lsl @@ -6,8 +6,7 @@ typealias Char = char; automaton A : Int { var ch1: Char = 'A'; var ch2: Char = 'a'; - var ch3: Char = 52; + var ch3: Char = '狐'; var ch4: Char = '*'; - var ch5: Char = ''; - var ch6: Char = 'S'; + var ch5: Char = 'S'; } \ No newline at end of file diff --git a/src/test/testdata/lsl/charLiterals.lsl b/src/test/testdata/lsl/charLiterals.lsl index f7ffc360..393e5aa3 100644 --- a/src/test/testdata/lsl/charLiterals.lsl +++ b/src/test/testdata/lsl/charLiterals.lsl @@ -6,8 +6,7 @@ typealias Char = char; automaton A : Int { var ch1: Char = '\u0041'; var ch2: Char = 'a'; - var ch3: Char = 52; + var ch3: Char = '\u72D0'; var ch4: Char = '\52'; - var ch5: Char = '\5'; - var ch6: Char = '\123'; + var ch5: Char = '\123'; } \ No newline at end of file