diff --git a/shared/src/main/scala/io/kaitai/struct/ClassTypeProvider.scala b/shared/src/main/scala/io/kaitai/struct/ClassTypeProvider.scala index 0dee55827..310d69482 100644 --- a/shared/src/main/scala/io/kaitai/struct/ClassTypeProvider.scala +++ b/shared/src/main/scala/io/kaitai/struct/ClassTypeProvider.scala @@ -68,7 +68,7 @@ class ClassTypeProvider(classSpecs: ClassSpecs, var topClass: ClassSpec) extends * @param inClass type specification to search member in * @param attrName name of a member to search for * @return member spec if found, or throws an exception - * @throws format.InvalidIdentifier if attribute name is not a valid name for a member + * @throws precompile.InvalidIdentifier if attribute name is not a valid name for a member * @throws precompile.FieldNotFoundError if attribute with such name is not found */ def resolveMember(inClass: ClassSpec, attrName: String): MemberSpec = { diff --git a/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala b/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala index d9e595dca..12a760121 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/AttrSpec.scala @@ -6,6 +6,7 @@ import io.kaitai.struct.datatype.DataType import io.kaitai.struct.datatype.DataType._ import io.kaitai.struct.exprlang.Ast.expr import io.kaitai.struct.exprlang.{Ast, Expressions} +import io.kaitai.struct.precompile.InvalidIdentifier import io.kaitai.struct.problems.KSYParseError import scala.collection.immutable.SortedMap diff --git a/shared/src/main/scala/io/kaitai/struct/format/Identifier.scala b/shared/src/main/scala/io/kaitai/struct/format/Identifier.scala index 2912eb9e9..8f7855ac9 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/Identifier.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/Identifier.scala @@ -1,6 +1,7 @@ package io.kaitai.struct.format import io.kaitai.struct.exprlang.Ast +import io.kaitai.struct.precompile.InvalidIdentifier import io.kaitai.struct.problems.KSYParseError /** @@ -37,10 +38,6 @@ case class NamedIdentifier(name: String) extends Identifier { override def humanReadable: String = name } -case class InvalidIdentifier(id: String) extends RuntimeException( - s"invalid ID: '$id', expected /${Identifier.ReIdentifier.toString}/" -) - object Identifier { val ReIdentifier = "^[a-z][a-z0-9_]*$".r diff --git a/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala b/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala index 1481cddcb..a9fc6b8f7 100644 --- a/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala +++ b/shared/src/main/scala/io/kaitai/struct/format/ParseUtils.scala @@ -2,6 +2,7 @@ package io.kaitai.struct.format import io.kaitai.struct.Utils import io.kaitai.struct.exprlang.{Ast, Expressions} +import io.kaitai.struct.precompile.InvalidIdentifier import io.kaitai.struct.problems.KSYParseError object ParseUtils { diff --git a/shared/src/main/scala/io/kaitai/struct/precompile/Exceptions.scala b/shared/src/main/scala/io/kaitai/struct/precompile/Exceptions.scala index 1ac6035bb..bc5dfb540 100644 --- a/shared/src/main/scala/io/kaitai/struct/precompile/Exceptions.scala +++ b/shared/src/main/scala/io/kaitai/struct/precompile/Exceptions.scala @@ -1,7 +1,7 @@ package io.kaitai.struct.precompile import io.kaitai.struct.datatype.DataType -import io.kaitai.struct.format.ClassSpec +import io.kaitai.struct.format.{ClassSpec, Identifier} import io.kaitai.struct.translators.MethodArgType /** @@ -9,6 +9,10 @@ import io.kaitai.struct.translators.MethodArgType * in source file. */ sealed abstract class ExpressionError(msg: String) extends RuntimeException(msg) + +class InvalidIdentifier(id: String) + extends ExpressionError(s"invalid ID: '$id', expected /${Identifier.ReIdentifier.toString}/") + class TypeMismatchError(msg: String) extends ExpressionError(msg) class TypeUndecidedError(msg: String) extends ExpressionError(msg) class WrongMethodCall(val dataType: MethodArgType, val methodName: String, val expectedSigs: Iterable[String], val actualSig: String) diff --git a/shared/src/main/scala/io/kaitai/struct/precompile/TypeValidator.scala b/shared/src/main/scala/io/kaitai/struct/precompile/TypeValidator.scala index d80741484..11fbd9909 100644 --- a/shared/src/main/scala/io/kaitai/struct/precompile/TypeValidator.scala +++ b/shared/src/main/scala/io/kaitai/struct/precompile/TypeValidator.scala @@ -239,8 +239,6 @@ class TypeValidator(specs: ClassSpecs) extends PrecompileStep { detector.validate(expr) None } catch { - case err: InvalidIdentifier => - Some(ErrorInInput(err, path ++ List(pathKey))) case err: ExpressionError => Some(ErrorInInput(err, path ++ List(pathKey))) } @@ -285,8 +283,6 @@ class TypeValidator(specs: ClassSpecs) extends PrecompileStep { detector.validate(expr) None } catch { - case err: InvalidIdentifier => - Some(ErrorInInput(err, path ++ List(pathKey))) case err: ExpressionError => Some(ErrorInInput(err, path ++ List(pathKey))) }