Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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,
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):
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
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,
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:
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")
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:
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,