# Path: ifj2017/interpreter/exceptions.py
# class InvalidCodeException(ValueError):
#     UNKNOWN_INSTRUCTION = 0
#     INVALID_OPERAND = 1
#     INVALID_OPERAND_COUNT = 2
#     MISSING_HEADER = 3
# 
#     def __init__(self, type_, line_index=None, line=None):
#         self._type = type_
#         self.line_index = line_index
#         self.line = line
# 
#     def __str__(self):
#         messages = {
#             self.UNKNOWN_INSTRUCTION: 'Unknown instruction on line {self.line_index}: {self.line}.',
#             self.INVALID_OPERAND: 'Invalid operand on line {self.line_index}: {self.line}.',
#             self.INVALID_OPERAND_COUNT: 'Invalid count of operands on line {self.line_index}: {self.line}.',
#             self.MISSING_HEADER: 'Missing .IFJcode17 header on line {self.line_index}.'
#         }
#         return messages.get(
#             self._type,
#             'Invalid line {self.line_index}: {self.line}.'
#         ).format(self=self)


import re
from enum import IntEnum
from typing import Match
from .exceptions import InvalidCodeException
        raise InvalidCodeException(InvalidCodeException.INVALID_OPERAND)

    def _resolve_constant(self, constant_match: Match[str]) -> None:
        type_, value = constant_match.groups()  # type: str, str
        type_ = type_.lower().strip()
        try:
            self.value = self.CONSTANT_MAPPING.get(type_)(value)
            if type_ == self.CONSTANT_MAPPING_REVERSE.get(bool):
                self.value = self.BOOL_LITERAL_MAPPING.get(value.lower())
            elif type_ == self.CONSTANT_MAPPING_REVERSE.get(str):
                self.value = unquote_escape_sequences(value=self.value)
        except ValueError:
            pass
        if self.value is None:
            raise InvalidCodeException(type_=InvalidCodeException.INVALID_OPERAND)
        self.type = TypeOperand.CONSTANT

    def _resolve_variable(self, variable_match: Match[str]) -> None:
        # type: (Match) -> None
        frame, name = variable_match.groups()
        if not (frame and name):
            raise InvalidCodeException(type_=InvalidCodeException.INVALID_OPERAND)
        self.frame = frame
        self.name = name
        self.type = TypeOperand.VARIABLE

    def _resolve_type(self, type_match: Match[str]) -> None:
        # type: (Match[str]) -> None
        self.data_type = type_match.group(1).lower()
        if self.data_type not in self.CONSTANT_MAPPING:

# Path: ifj2017/interpreter/exceptions.py
# class InvalidCodeException(ValueError):
#     UNKNOWN_INSTRUCTION = 0
#     INVALID_OPERAND = 1
#     INVALID_OPERAND_COUNT = 2
#     MISSING_HEADER = 3
# 
#     def __init__(self, type_, line_index=None, line=None):
#         self._type = type_
#         self.line_index = line_index
#         self.line = line
# 
#     def __str__(self):
#         messages = {
#             self.UNKNOWN_INSTRUCTION: 'Unknown instruction on line {self.line_index}: {self.line}.',
#             self.INVALID_OPERAND: 'Invalid operand on line {self.line_index}: {self.line}.',
#             self.INVALID_OPERAND_COUNT: 'Invalid count of operands on line {self.line_index}: {self.line}.',
#             self.MISSING_HEADER: 'Missing .IFJcode17 header on line {self.line_index}.'
#         }
#         return messages.get(
#             self._type,
#             'Invalid line {self.line_index}: {self.line}.'
#         ).format(self=self)


# Path: ifj2017/interpreter/operand.py
import re
from enum import IntEnum
from typing import Match
from .exceptions import InvalidCodeException

        raise InvalidCodeException(InvalidCodeException.INVALID_OPERAND)

    def _resolve_constant(self, constant_match: Match[str]) -> None:
        type_, value = constant_match.groups()  # type: str, str
        type_ = type_.lower().strip()
        try:
            self.value = self.CONSTANT_MAPPING.get(type_)(value)
            if type_ == self.CONSTANT_MAPPING_REVERSE.get(bool):
                self.value = self.BOOL_LITERAL_MAPPING.get(value.lower())
            elif type_ == self.CONSTANT_MAPPING_REVERSE.get(str):
                self.value = unquote_escape_sequences(value=self.value)
        except ValueError:
            pass
        if self.value is None:
            raise InvalidCodeException(type_=InvalidCodeException.INVALID_OPERAND)
        self.type = TypeOperand.CONSTANT

    def _resolve_variable(self, variable_match: Match[str]) -> None:
        # type: (Match) -> None
        frame, name = variable_match.groups()
        if not (frame and name):
            raise InvalidCodeException(type_=InvalidCodeException.INVALID_OPERAND)
        self.frame = frame
        self.name = name
        self.type = TypeOperand.VARIABLE

    def _resolve_type(self, type_match: Match[str]) -> None:
        # type: (Match[str]) -> None
        self.data_type = type_match.group(1).lower()
        if self.data_type not in self.CONSTANT_MAPPING:

            raise InvalidCodeException(type_=InvalidCodeException.INVALID_OPERAND)