Module Perk.Parse_tags

Parses a ctags-generated tags file.

type parse_result =
  1. | Comment
  2. | Prototype of string * string * string
  3. | Typedef of string
  4. | Other

The result of parsing a tags file.

val generate_tags : string list -> unit

Generates the tags file, by first expanding the libraries and merging them, and then calling ctags.

val string_of_parse_result : parse_result -> string

Debug function to print parsed tags file

val read_file : string -> string list

Reads a file.

val parse_line : string -> parse_result

Parses a tags line:

  • p means that the line represents a prototype
  • t means the line represents a typedef.
val parse_ret_type : string -> Ctype_ast.ctype

Parses the return type of a C prototype

val parse_signature : string -> Ctype_ast.typed_var list

Parses the signature of a C prototype

val is_proto : parse_result -> bool

Checks if a parse_result is a prototype.

val is_typedef : parse_result -> bool

Checks if a parse_result is a typedef.

val to_ctypes : parse_result -> (string * Ctype_ast.ctype * Ctype_ast.typed_var list) option

Converts a parse result to a C type.

val string_of_ctypes : (string * Ctype_ast.ctype * Ctype_ast.typed_var list) -> string

Debug function to print C prototype types.

val get_typedef : parse_result -> string
val is_spec_type : Ctype_ast.specifier -> bool
val is_pointer_level : Ctype_ast.specifier -> bool
val solve_specifiers : Ctype_ast.specifier list -> Ctype_ast.specifier

Given a C specifier list, converts it to a stdint type.

val get_type_from_spec_list : Ctype_ast.specifier list -> Ctype_ast.specifier

Given a specifier list, returns the corresponding type.

val remove_tags : unit -> unit
val remove_libs_expanded : unit -> unit
val perktype_of_sort : Ctype_ast.specifier -> Ast.perktype_partial

Given a basic C sort, returns the corresponding base type

val wrap_perktype_in_ptrs : int -> Ast.perktype -> Ast.perktype_partial

Wraps a type in pointers, a positive number of times.

Transforms C qualifiers to perk qualifiers

val perktype_of_ctype : Ctype_ast.ctype -> Ast.perktype

Transforms a c type to a perk type

val perktype_of_arg : Ctype_ast.typed_var -> Ast.perktype

Given a C prototype argument, returns its type.

Returns the perk types of each C prototype in the tags file.

val get_prototype_types : unit -> (string * Ast.perktype) list