How to use the gilgamesh.disassembly.parser.TokenType function in gilgamesh

To help you get started, we’ve selected a few gilgamesh examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
OPERAND_LABEL = auto()
    OPERATION = auto()
    PC = auto()
    SEPARATOR_LINE = auto()
    STACK_MANIPULATION_HEADER = auto()
    SUGGESTED_ASSERTION = auto()
    SUGGESTED_ASSERTION_TYPE = auto()
    UNKNOWN_REASON = auto()
    UNKNOWN_STATE_HEADER = auto()


HEADER_TOKENS = {
    TokenType.ASSERTED_STATE_HEADER,
    TokenType.FATAL_STACK_MANIPULATION_HEADER,
    TokenType.JUMP_TABLE_HEADER,
    TokenType.KNOWN_STATE_HEADER,
    TokenType.SEPARATOR_LINE,
    TokenType.STACK_MANIPULATION_HEADER,
    TokenType.UNKNOWN_STATE_HEADER,
}

EDITABLE_TOKEN_TYPES = {
    TokenType.SUGGESTED_ASSERTION: TokenType.ASSERTION,
    TokenType.SUGGESTED_ASSERTION_TYPE: TokenType.ASSERTION_TYPE,
}

EDITABLE_TOKENS = {
    *EDITABLE_TOKEN_TYPES.keys(),
    TokenType.ASSERTION,
    TokenType.ASSERTION_TYPE,
    TokenType.COMMENT,
    TokenType.JUMP_TABLE_ENTRY,
github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
TokenType.SUGGESTED_ASSERTION_TYPE: TokenType.ASSERTION_TYPE,
}

EDITABLE_TOKENS = {
    *EDITABLE_TOKEN_TYPES.keys(),
    TokenType.ASSERTION,
    TokenType.ASSERTION_TYPE,
    TokenType.COMMENT,
    TokenType.JUMP_TABLE_ENTRY,
    TokenType.LABEL,
    TokenType.OPERAND_LABEL,
}

EQUIVALENT_TOKENS = {
    TokenType.FATAL_STACK_MANIPULATION_HEADER: TokenType.STACK_MANIPULATION_HEADER,
    TokenType.HIGHLIGHTED_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_COMPLETE_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_LABEL: TokenType.LABEL,
    TokenType.JUMP_TABLE_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
}


@dataclass
class Token:
    typ: TokenType
    val: str = ""


class Parser:
    def __init__(self, text: str, base_line_n: int):
github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
EDITABLE_TOKENS = {
    *EDITABLE_TOKEN_TYPES.keys(),
    TokenType.ASSERTION,
    TokenType.ASSERTION_TYPE,
    TokenType.COMMENT,
    TokenType.JUMP_TABLE_ENTRY,
    TokenType.LABEL,
    TokenType.OPERAND_LABEL,
}

EQUIVALENT_TOKENS = {
    TokenType.FATAL_STACK_MANIPULATION_HEADER: TokenType.STACK_MANIPULATION_HEADER,
    TokenType.HIGHLIGHTED_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_COMPLETE_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_LABEL: TokenType.LABEL,
    TokenType.JUMP_TABLE_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
}


@dataclass
class Token:
    typ: TokenType
    val: str = ""


class Parser:
    def __init__(self, text: str, base_line_n: int):
        self.lines = text.splitlines()
        self.line_idx = 0
        self.base_line_n = base_line_n
github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
UNKNOWN_REASON = auto()
    UNKNOWN_STATE_HEADER = auto()


HEADER_TOKENS = {
    TokenType.ASSERTED_STATE_HEADER,
    TokenType.FATAL_STACK_MANIPULATION_HEADER,
    TokenType.JUMP_TABLE_HEADER,
    TokenType.KNOWN_STATE_HEADER,
    TokenType.SEPARATOR_LINE,
    TokenType.STACK_MANIPULATION_HEADER,
    TokenType.UNKNOWN_STATE_HEADER,
}

EDITABLE_TOKEN_TYPES = {
    TokenType.SUGGESTED_ASSERTION: TokenType.ASSERTION,
    TokenType.SUGGESTED_ASSERTION_TYPE: TokenType.ASSERTION_TYPE,
}

EDITABLE_TOKENS = {
    *EDITABLE_TOKEN_TYPES.keys(),
    TokenType.ASSERTION,
    TokenType.ASSERTION_TYPE,
    TokenType.COMMENT,
    TokenType.JUMP_TABLE_ENTRY,
    TokenType.LABEL,
    TokenType.OPERAND_LABEL,
}

EQUIVALENT_TOKENS = {
    TokenType.FATAL_STACK_MANIPULATION_HEADER: TokenType.STACK_MANIPULATION_HEADER,
    TokenType.HIGHLIGHTED_OPERAND_LABEL: TokenType.OPERAND_LABEL,
github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
TokenType.SUGGESTED_ASSERTION: TokenType.ASSERTION,
    TokenType.SUGGESTED_ASSERTION_TYPE: TokenType.ASSERTION_TYPE,
}

EDITABLE_TOKENS = {
    *EDITABLE_TOKEN_TYPES.keys(),
    TokenType.ASSERTION,
    TokenType.ASSERTION_TYPE,
    TokenType.COMMENT,
    TokenType.JUMP_TABLE_ENTRY,
    TokenType.LABEL,
    TokenType.OPERAND_LABEL,
}

EQUIVALENT_TOKENS = {
    TokenType.FATAL_STACK_MANIPULATION_HEADER: TokenType.STACK_MANIPULATION_HEADER,
    TokenType.HIGHLIGHTED_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_COMPLETE_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_LABEL: TokenType.LABEL,
    TokenType.JUMP_TABLE_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
}


@dataclass
class Token:
    typ: TokenType
    val: str = ""


class Parser:
github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
def add_line(self, *args) -> None:
        if args:
            self.add(*args)
        self.add(TokenType.NEWLINE)
        self.line_idx += 1
        invalidate(self, "line")
        invalidate(self, "words")
github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
TokenType.STACK_MANIPULATION_HEADER,
    TokenType.UNKNOWN_STATE_HEADER,
}

EDITABLE_TOKEN_TYPES = {
    TokenType.SUGGESTED_ASSERTION: TokenType.ASSERTION,
    TokenType.SUGGESTED_ASSERTION_TYPE: TokenType.ASSERTION_TYPE,
}

EDITABLE_TOKENS = {
    *EDITABLE_TOKEN_TYPES.keys(),
    TokenType.ASSERTION,
    TokenType.ASSERTION_TYPE,
    TokenType.COMMENT,
    TokenType.JUMP_TABLE_ENTRY,
    TokenType.LABEL,
    TokenType.OPERAND_LABEL,
}

EQUIVALENT_TOKENS = {
    TokenType.FATAL_STACK_MANIPULATION_HEADER: TokenType.STACK_MANIPULATION_HEADER,
    TokenType.HIGHLIGHTED_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_COMPLETE_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_LABEL: TokenType.LABEL,
    TokenType.JUMP_TABLE_OPERAND_LABEL: TokenType.OPERAND_LABEL,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
    TokenType.JUMP_TABLE_UNKNOWN_ENTRY: TokenType.JUMP_TABLE_ENTRY,
}


@dataclass
class Token:
github AndreaOrru / gilgamesh / gilgamesh / disassembly / parser.py View on Github external
LAST_KNOWN_STATE_CHANGE = auto()
    NEWLINE = auto()
    OPERAND = auto()
    OPERAND_LABEL = auto()
    OPERATION = auto()
    PC = auto()
    SEPARATOR_LINE = auto()
    STACK_MANIPULATION_HEADER = auto()
    SUGGESTED_ASSERTION = auto()
    SUGGESTED_ASSERTION_TYPE = auto()
    UNKNOWN_REASON = auto()
    UNKNOWN_STATE_HEADER = auto()


HEADER_TOKENS = {
    TokenType.ASSERTED_STATE_HEADER,
    TokenType.FATAL_STACK_MANIPULATION_HEADER,
    TokenType.JUMP_TABLE_HEADER,
    TokenType.KNOWN_STATE_HEADER,
    TokenType.SEPARATOR_LINE,
    TokenType.STACK_MANIPULATION_HEADER,
    TokenType.UNKNOWN_STATE_HEADER,
}

EDITABLE_TOKEN_TYPES = {
    TokenType.SUGGESTED_ASSERTION: TokenType.ASSERTION,
    TokenType.SUGGESTED_ASSERTION_TYPE: TokenType.ASSERTION_TYPE,
}

EDITABLE_TOKENS = {
    *EDITABLE_TOKEN_TYPES.keys(),
    TokenType.ASSERTION,