ida_srclang

Third-party compiler support.

Attributes

SWIG_PYTHON_LEGACY_BOOL

SRCLANG_C

SRCLANG_CPP

C++.

SRCLANG_OBJC

Objective-C.

SRCLANG_SWIFT

Swift (not supported yet)

SRCLANG_GO

Golang (not supported yet)

Functions

select_parser_by_name(→ bool)

Set the parser with the given name as the current parser. Pass nullptr or an empty string to select the default parser.

select_parser_by_srclang(→ bool)

Set the parser that supports the given language(s) as the current parser. The selected parser must support all languages specified by the given srclang_t.

get_selected_parser_name(→ str)

Get current parser name.

set_parser_argv(→ int)

Set the command-line args to use for invocations of the parser with the given name

parse_decls_for_srclang(→ int)

Parse type declarations in the specified language

parse_decls_with_parser_ext(→ int)

Parse type declarations using the parser with the specified name

get_parser_option(→ str)

Get option for the parser with the specified name

set_parser_option(→ bool)

Set option for the parser with the specified name

parse_decls_with_parser(→ int)

Parse type declarations using the parser with the specified name

Module Contents

ida_srclang.SWIG_PYTHON_LEGACY_BOOL
ida_srclang.SRCLANG_C
ida_srclang.SRCLANG_CPP

C++.

ida_srclang.SRCLANG_OBJC

Objective-C.

ida_srclang.SRCLANG_SWIFT

Swift (not supported yet)

ida_srclang.SRCLANG_GO

Golang (not supported yet)

ida_srclang.select_parser_by_name(name: str) bool

Set the parser with the given name as the current parser. Pass nullptr or an empty string to select the default parser.

Returns:

false if no parser was found with the given name

ida_srclang.select_parser_by_srclang(lang: srclang_t) bool

Set the parser that supports the given language(s) as the current parser. The selected parser must support all languages specified by the given srclang_t.

Returns:

false if no such parser was found

ida_srclang.get_selected_parser_name() str

Get current parser name.

Returns:

success

ida_srclang.set_parser_argv(parser_name: str, argv: str) int

Set the command-line args to use for invocations of the parser with the given name

Parameters:
  • parser_name – name of the target parser

  • argv – argument list

Returns:

-1: no parser was found with the given name

Returns:

-2: the operation is not supported by the given parser

Returns:

0: success

ida_srclang.parse_decls_for_srclang(lang: srclang_t, til: til_t, input: str, is_path: bool) int

Parse type declarations in the specified language

Parameters:
  • lang – the source language(s) expected in the input

  • til – type library to store the types

  • input – input source. can be a file path or decl string

  • is_path – true if input parameter is a path to a source file, false if the input is an in-memory source snippet

Returns:

-1: no parser was found that supports the given source language(s)

Returns:

else: the number of errors encountered in the input source

ida_srclang.parse_decls_with_parser_ext(parser_name: str, til: til_t, input: str, hti_flags: int) int

Parse type declarations using the parser with the specified name

Parameters:
  • parser_name – name of the target parser

  • til – type library to store the types

  • input – input source. can be a file path or decl string

  • hti_flags – combination of Type formatting flags

Returns:

-1: no parser was found with the given name

Returns:

else: the number of errors encountered in the input source

ida_srclang.get_parser_option(parser_name: str, option_name: str) str

Get option for the parser with the specified name

Parameters:
  • parser_name – name of the target parser

  • option_name – parser option name

Returns:

success

ida_srclang.set_parser_option(parser_name: str, option_name: str, option_value: str) bool

Set option for the parser with the specified name

Parameters:
  • parser_name – name of the target parser

  • option_name – parser option name

  • option_value – parser option value

Returns:

success

ida_srclang.parse_decls_with_parser(parser_name: str, til: til_t, input: str, is_path: bool) int

Parse type declarations using the parser with the specified name

Parameters:
  • parser_name – name of the target parser

  • til – type library to store the types

  • input – input source. can be a file path or decl string

  • is_path – true if input parameter is a path to a source file, false if the input is an in-memory source snippet

Returns:

-1: no parser was found with the given name

Returns:

else: the number of errors encountered in the input source