Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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

/**
Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
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

/**
* Base class for all expression-related errors, not localized to a certain path
* 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,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)))
}
Expand Down Expand Up @@ -269,8 +267,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)))
}
Expand Down
Loading