package spdx_licenses

  1. Overview
  2. Docs

Module Spdx_licensesSource

Sourcetype user_defined_license = {
  1. document_ref : string option;
  2. license_ref : string;
}

"DocumentRef-" idstring ":""LicenseRef-" idstring

Sourcetype simple_license =
  1. | LicenseID of string
    (*

    license-id

    *)
  2. | LicenseIDPlus of string
    (*

    license-id '+' (the '+' isn't contained in the string)

    *)
  3. | LicenseRef of user_defined_license
    (*

    A SPDX user defined license reference

    *)

simple-expression

Sourcetype user_defined_addition = {
  1. document_ref : string option;
  2. addition_ref : string;
}

"DocumentRef-" idstring ":""AdditionRef-" idstring

Sourcetype addition =
  1. | Exception of string
    (*

    license-exception-id

    *)
  2. | AdditionRef of user_defined_addition
    (*

    A SPDX user defined addition reference

    *)

addition-expression

Sourcetype t =
  1. | Simple of simple_license
    (*

    simple-expression

    *)
  2. | WITH of simple_license * addition
    (*

    simple-expression "WITH" addition-expression

    *)
  3. | AND of t * t
    (*

    compound-expression "AND" compound-expression

    *)
  4. | OR of t * t
    (*

    compound-expression "OR" compound-expression

    *)

license-expression

Sourcetype error = [
  1. | `InvalidLicenseID of string
  2. | `InvalidExceptionID of string
  3. | `ParseError
]

The errors returned by the parser

Sourceval parse : string -> (t, [> error ]) result

parse str parses str according to the syntax described in: https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/

Sourceval to_string : t -> string

to_string license returns a normalized string corresponding to license in a valid SPDX license expression format.

Sourceval valid_license_ids : string list

valid_license_ids gives the list of valid license IDs. The list does not contain deprecated licenses. See: https://spdx.org/licenses/

Sourceval valid_exception_ids : string list

valid_exception_ids gives the list of valid exception IDs. The list does not contain deprecated exceptions. See: https://spdx.org/licenses/exceptions-index.html