Textual format¶
Parsing IR-code from a textual form.
-
exception
ppci.irutils.reader.IrParseException¶ Exception raised when reading of IR-code fails.
-
class
ppci.irutils.reader.Reader¶ Read IR-code from file
-
at_keyword(keyword)¶ Test if we are at some keyword.
-
consume_keyword(keyword)¶ Consume a specific identifier.
-
define_value(value)¶ Define a value
-
error(msg)¶ Something went wrong.
-
find_value(name, ty=ir-typ i32)¶ Try hard to find a value.
If the value is undefined, create a placeholder undefined value.
-
parse_assignment()¶ Parse an instruction with shape ‘ty’ ‘name’ ‘=’ …
-
parse_block(function)¶ Read a single block from file
-
parse_external(module)¶ Parse external variable.
-
parse_function(binding)¶ Parse a function or procedure
-
parse_module()¶ Entry for recursive descent parser
-
parse_statement()¶ Parse a single instruction line
-
parse_type()¶ Parse a single type
-
parse_value_ref(ty=ir-typ ptr)¶ Parse a reference to another variable.
-
read(f) → ppci.ir.Module¶ Read ir code from file f
-
-
ppci.irutils.reader.read_module(f) → ppci.ir.Module¶ Read an ir-module from file.
Parameters: f – A file like object ready to be read in text modus. Returns: The loaded ir-module.
Writing IR-code into a textual format.
-
class
ppci.irutils.writer.Writer(file=None, extra_indent='')¶ Write ir-code to file
-
write(module: ppci.ir.Module, verify=True)¶ Write ir-code to file f
-
-
ppci.irutils.writer.print_module(module, file=None, verify=True)¶ Print an ir-module as text.
Parameters: - module (
ir.Module) – The module to turn into textual format. - file – An optional file like object to write to. Defaults to stdout.
- verify (bool) – A boolean indicating whether or not the module should be verified before writing.
- module (