osaca.parser package¶
Parser module for parsing the assembly code.
osaca.parser.attr_dict module¶
Attribute Dictionary to access dictionary entries as attributes.
osaca.parser.base_parser module¶
Parser superclass of specific parsers.
-
class
BaseParser
[source]¶ Bases:
object
-
COMMENT_ID
= 'comment'¶
-
DIRECTIVE_ID
= 'directive'¶
-
IMMEDIATE_ID
= 'immediate'¶
-
LABEL_ID
= 'label'¶
-
IDENTIFIER_ID
= 'identifier'¶
-
MEMORY_ID
= 'memory'¶
-
REGISTER_ID
= 'register'¶
-
SEGMENT_EXT_ID
= 'segment_extension'¶
-
INSTRUCTION_ID
= 'instruction'¶
-
OPERANDS_ID
= 'operands'¶
-
static
detect_ISA
(file_content)[source]¶ Detect the ISA of the assembly based on the used registers and return the ISA code.
-
parse_file
(file_content, start_line=0)[source]¶ Parse assembly file. This includes not extracting of the marked kernel and the parsing of the instruction forms.
Parameters: - file_content (str) – assembly code
- start_line (int) – offset, if first line in file_content is meant to be not 1
Returns: list of instruction forms
-
osaca.parser.parser_AArch64v81 module¶
osaca.parser.parser_x86att module¶
-
class
ParserX86ATT
[source]¶ Bases:
osaca.parser.base_parser.BaseParser
-
parse_line
(line, line_number=None)[source]¶ Parse line and return instruction form.
Parameters: - line (str) – line of assembly code
- line_number (int, optional) – default None, identifier of instruction form
Returns: dict
– parsed asm line (comment, label, directive or instruction form)
-
Module contents¶
Collection of parsers supported by OSACA.
Only the parser below will be exported, so please add new parsers to __all__.
-
class
AttrDict
(*args, **kwargs)[source]¶ Bases:
dict
-
class
BaseParser
[source]¶ Bases:
object
-
COMMENT_ID
= 'comment'¶
-
DIRECTIVE_ID
= 'directive'¶
-
IMMEDIATE_ID
= 'immediate'¶
-
LABEL_ID
= 'label'¶
-
IDENTIFIER_ID
= 'identifier'¶
-
MEMORY_ID
= 'memory'¶
-
REGISTER_ID
= 'register'¶
-
SEGMENT_EXT_ID
= 'segment_extension'¶
-
INSTRUCTION_ID
= 'instruction'¶
-
OPERANDS_ID
= 'operands'¶
-
static
detect_ISA
(file_content)[source]¶ Detect the ISA of the assembly based on the used registers and return the ISA code.
-
parse_file
(file_content, start_line=0)[source]¶ Parse assembly file. This includes not extracting of the marked kernel and the parsing of the instruction forms.
Parameters: - file_content (str) – assembly code
- start_line (int) – offset, if first line in file_content is meant to be not 1
Returns: list of instruction forms
-
-
class
ParserX86ATT
[source]¶ Bases:
osaca.parser.base_parser.BaseParser
-
parse_line
(line, line_number=None)[source]¶ Parse line and return instruction form.
Parameters: - line (str) – line of assembly code
- line_number (int, optional) – default None, identifier of instruction form
Returns: dict
– parsed asm line (comment, label, directive or instruction form)
-
-
class
ParserAArch64
[source]¶ Bases:
osaca.parser.base_parser.BaseParser
-
parse_line
(line, line_number=None)[source]¶ Parse line and return instruction form.
Parameters: - line (str) – line of assembly code
- line_number (int, optional) – identifier of instruction form, defautls to None
Returns: dict – parsed asm line (comment, label, directive or instruction form)
-
parse_instruction
(instruction)[source]¶ Parse instruction in asm line.
Parameters: instruction (str) – Assembly line string. Returns: dict – parsed instruction form
-
resolve_range_list
(operand)[source]¶ Resolve range or list register operand to list of registers. Returns None if neither list nor range
-