package frama-c

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Data.EnumSource

Enum factory.

You shall start by declaring a dictionary with Enum.dictionary for your values. Then, populate the dictionary with Enum.tag values. Finally, you shall call Enum.publish to obtain a new data module for your type.

You have two options for computing tags: either you provide values when declaring tags, and these tags will be associated to registered values for both directions; alternatively you might provide a ~tag function to Enum.publish.

The difficulty when providing values only at tag definition is to ensure that all possible value has been registered.

The conversion values from and to json may fail when no value has been registered with tags.

Sourcetype 'a dictionary
Sourcetype 'a tag
Sourcetype 'a prefix
Sourceval tag_name : 'a tag -> string
Sourceval dictionary : unit -> 'a dictionary

Creates an opened, empty dictionary.

Sourceval tag : name:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> ?value:'a -> 'a dictionary -> 'a tag

Register a new tag in the dictionary. The default label is the capitalized name. The provided value, if any, will be used for decoding json tags. If would be used also for encoding values to json tags if no ~tag function is provided when publishing the dictionary. Registered values must be hashable with Hashtbl.hash function.

You may register a new tag after the dictionary has been published.

Sourceval add : name:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> ?value:'a -> 'a dictionary -> unit

Same as tag but to not return the associated tag.

Sourceval find : 'a dictionary -> 'a tag -> 'a

Returns the value associated to some tag.

  • raises Not_found

    if no value is associated to the tag.

Sourceval lookup : 'a dictionary -> 'a -> 'a tag

Returns the tag associated to a value.

  • raises Not_found

    if no value is associated to the tag.

Sourceval find_tag : 'a dictionary -> string -> 'a tag

Returns the tag from its name.

  • raises Not_found

    if no tag has been registered with this name.

Sourceval prefix : name:string -> ?var:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> 'a dictionary -> 'a prefix

Register a new prefix tag in the dictionary. The default label is the capitalized prefix. To decoding from json is provided to prefix tags. Encoding is done by emitting tags with form 'prefix:*'. The variable part of the prefix is documented as 'prefix:xxx' when ~var:"xxx" is provided.

You may register a new prefix-tag after the dictionary has been published.

Sourceval instance : 'a prefix -> string -> 'a tag

Returns the tag for a value associated with the given prefix.

Sourceval extends : name:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> ?value:'a -> 'a prefix -> 'a tag

Publish a new instance in the documentation.

Sourceval tags : 'a dictionary -> Tag.t list

Obtain all the tags registered in the dictionary so far.

Sourceval set_lookup : 'a dictionary -> ('a -> 'a tag) -> unit

Set tagging function for values. If the lookup function raises `Not_found`, the dictionary will use the tag associated with the provided value, if any.

Sourceval publish : package:Package.package -> name:string -> descr:Frama_c_kernel.Markdown.text -> 'a dictionary -> (module S with type t = 'a)

Publish the dictionary. No more tag nor prefix can be added afterwards. If no ~tag function is provided, the values registered with tags are used.

OCaml

Innovation. Community. Security.