···11+v1.4.0 (03/07/2025)
22+-------------------
33+44+- Upgrade to Version 3.27.0 of the SPDX License List (@kit-ty-kate)
55+66+v1.3.0 (19/01/2024)
77+-------------------
88+99+- Upgrade to Version 3.26.0 of the SPDX License List (@kit-ty-kate)
1010+1111+v1.2.0 (06/01/2023)
1212+-------------------
1313+1414+- Upgrade to Version 3.19 of the SPDX License List (@kit-ty-kate)
1515+- Always sort the lists of licenses and exceptions the same way to make it easier to diff with later changes (@kit-ty-kate)
1616+1717+v1.1.0 (05/09/2021)
1818+-------------------
1919+2020+- Increase the minimal required version of OCaml from 4.03 to 4.08 (@kit-ty-kate)
2121+2222+v1.0.0 (29/07/2021)
2323+-------------------
2424+2525+- First release: an (hopefully) complete and correct SPDX license expression parser and some tests. (@kit-ty-kate)
+18
vendor/opam/spdx_licenses/LICENSE.txt
···11+Copyright (c) 2021 Kate <kit.ty.kate@disroot.org>
22+33+Permission is hereby granted, free of charge, to any person obtaining a copy of
44+this software and associated documentation files (the "Software"), to deal in
55+the Software without restriction, including without limitation the rights to
66+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
77+the Software, and to permit persons to whom the Software is furnished to do so,
88+subject to the following conditions:
99+1010+The above copyright notice and this permission notice shall be included in all
1111+copies or substantial portions of the Software.
1212+1313+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1414+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
1515+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
1616+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
1717+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1818+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+8
vendor/opam/spdx_licenses/README.md
···11+spdx_licenses is an OCaml library aiming to provide an up-to-date and strict SPDX License Expression parser.
22+33+It implements the format described in: https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/
44+55+To install it simply call:
66+```
77+$ opam install spdx_licenses
88+```
···11+(* SPDX-License-Identifier: MIT *)
22+33+val list : string list
+40
vendor/opam/spdx_licenses/src/parser.mly
···11+/* SPDX-License-Identifier: MIT */
22+33+%token <string> ID
44+%token <string> IDPLUS
55+%token <string option * string> REF
66+%token <string option * string> ADREF
77+%token WITH
88+%token AND
99+%token OR
1010+%token LPAREN
1111+%token RPAREN
1212+%token EOF
1313+1414+%left OR
1515+%left AND
1616+1717+%start main
1818+%type <Types.t> main
1919+2020+%%
2121+2222+main: body EOF { $1 }
2323+2424+simple:
2525+ | ID { Types.LicenseID $1 }
2626+ | IDPLUS { Types.LicenseIDPlus $1 }
2727+ | REF { let (document_ref, license_ref) = $1 in
2828+ Types.LicenseRef {Types.document_ref; license_ref} }
2929+3030+addition:
3131+ | ID { Types.Exception $1 }
3232+ | ADREF { let (document_ref, addition_ref) = $1 in
3333+ Types.AdditionRef {Types.document_ref; addition_ref} }
3434+3535+body:
3636+ | simple { Types.Simple $1 }
3737+ | simple WITH addition { Types.WITH ($1, $3) }
3838+ | body AND body { Types.AND ($1, $3) }
3939+ | body OR body { Types.OR ($1, $3) }
4040+ | LPAREN body RPAREN { $2 }
+129
vendor/opam/spdx_licenses/src/spdx_licenses.ml
···11+(* SPDX-License-Identifier: MIT *)
22+33+type user_defined_license = Types.user_defined_license = {
44+ document_ref : string option;
55+ license_ref : string;
66+}
77+88+type simple_license = Types.simple_license =
99+ | LicenseID of string
1010+ | LicenseIDPlus of string
1111+ | LicenseRef of user_defined_license
1212+1313+type user_defined_addition = Types.user_defined_addition = {
1414+ document_ref : string option;
1515+ addition_ref : string;
1616+}
1717+1818+type addition = Types.addition =
1919+ | Exception of string
2020+ | AdditionRef of user_defined_addition
2121+2222+type t = Types.t =
2323+ | Simple of simple_license
2424+ | WITH of simple_license * addition
2525+ | AND of t * t
2626+ | OR of t * t
2727+2828+type error = [
2929+ | `InvalidLicenseID of string
3030+ | `InvalidExceptionID of string
3131+ | `ParseError
3232+]
3333+3434+let ( >>= ) = Result.bind
3535+let ( >|= ) x f = Result.map f x
3636+3737+let valid_license_ids = LicenseIDs.list
3838+let valid_exception_ids = ExceptionIDs.list
3939+4040+let uppercased_valid_license_ids =
4141+ List.map (fun x -> (x, String.uppercase_ascii x)) valid_license_ids
4242+4343+let uppercased_valid_exception_ids =
4444+ List.map (fun x -> (x, String.uppercase_ascii x)) valid_exception_ids
4545+4646+let normalize_license_id id =
4747+ let eq = String.equal (String.uppercase_ascii id) in
4848+ match List.find (fun (_, up) -> eq up) uppercased_valid_license_ids with
4949+ | (x, _) -> Ok x
5050+ | exception Not_found -> Error (`InvalidLicenseID id)
5151+5252+let normalize_exception_id id =
5353+ let eq = String.equal (String.uppercase_ascii id) in
5454+ match List.find (fun (_, up) -> eq up) uppercased_valid_exception_ids with
5555+ | (x, _) -> Ok x
5656+ | exception Not_found -> Error (`InvalidExceptionID id)
5757+5858+let normalize_simple = function
5959+ | LicenseID id -> normalize_license_id id >|= fun id -> LicenseID id
6060+ | LicenseIDPlus id -> normalize_license_id id >|= fun id -> LicenseIDPlus id
6161+ | LicenseRef _ as x -> Ok x
6262+6363+let normalize_addition = function
6464+ | Exception exc -> normalize_exception_id exc >|= fun exc -> Exception exc
6565+ | AdditionRef _ as x -> Ok x
6666+6767+let rec normalize = function
6868+ | Simple license ->
6969+ normalize_simple license >|= fun license ->
7070+ Simple license
7171+ | WITH (simple, addition) ->
7272+ normalize_simple simple >>= fun simple ->
7373+ normalize_addition addition >|= fun addition ->
7474+ WITH (simple, addition)
7575+ | AND (x, y) ->
7676+ normalize x >>= fun x ->
7777+ normalize y >|= fun y ->
7878+ AND (x, y)
7979+ | OR (x, y) ->
8080+ normalize x >>= fun x ->
8181+ normalize y >|= fun y ->
8282+ OR (x, y)
8383+8484+let parse s =
8585+ let lexbuf = Lexing.from_string s in
8686+ match Parser.main Lexer.main lexbuf with
8787+ | license -> normalize license
8888+ | exception (Lexer.Error | Parsing.Parse_error) -> Error `ParseError
8989+9090+let user_defined_license_to_string = function
9191+ | {document_ref = None; license_ref} ->
9292+ "LicenseRef-"^license_ref
9393+ | {document_ref = Some document_ref; license_ref} ->
9494+ "DocumentRef-"^document_ref^":"^"LicenseRef-"^license_ref
9595+9696+let simple_to_string = function
9797+ | LicenseID x -> x
9898+ | LicenseIDPlus x -> x^"+"
9999+ | LicenseRef user_def -> user_defined_license_to_string user_def
100100+101101+let user_defined_addition_to_string = function
102102+ | {document_ref = None; addition_ref} ->
103103+ "AdditionRef-"^addition_ref
104104+ | {document_ref = Some document_ref; addition_ref} ->
105105+ "DocumentRef-"^document_ref^":"^"AdditionRef-"^addition_ref
106106+107107+let addition_to_string = function
108108+ | Exception x -> x
109109+ | AdditionRef user_def -> user_defined_addition_to_string user_def
110110+111111+let to_string =
112112+ let rec aux ~prev = function
113113+ | Simple x -> simple_to_string x
114114+ | WITH (x, addition) ->
115115+ simple_to_string x^" WITH "^addition_to_string addition
116116+ | AND (x, y) ->
117117+ let s = aux ~prev:`AND x^" AND "^aux ~prev:`AND y in
118118+ begin match prev with
119119+ | (`None | `AND) -> s
120120+ | `OR -> "("^s^")"
121121+ end
122122+ | OR (x, y) ->
123123+ let s = aux ~prev:`OR x^" OR "^aux ~prev:`OR y in
124124+ begin match prev with
125125+ | (`None | `OR) -> s
126126+ | `AND -> "("^s^")"
127127+ end
128128+ in
129129+ aux ~prev:`None
+56
vendor/opam/spdx_licenses/src/spdx_licenses.mli
···11+(* SPDX-License-Identifier: MIT *)
22+33+(** ["DocumentRef-" idstring ":"]"LicenseRef-" idstring *)
44+type user_defined_license = {
55+ document_ref : string option;
66+ license_ref : string;
77+}
88+99+(** simple-expression *)
1010+type simple_license =
1111+ | LicenseID of string (** license-id *)
1212+ | LicenseIDPlus of string (** license-id '+' (the '+' isn't contained in the string) *)
1313+ | LicenseRef of user_defined_license (** A SPDX user defined license reference *)
1414+1515+(** ["DocumentRef-" idstring ":"]"AdditionRef-" idstring *)
1616+type user_defined_addition = {
1717+ document_ref : string option;
1818+ addition_ref : string;
1919+}
2020+2121+(** addition-expression *)
2222+type addition =
2323+ | Exception of string (** license-exception-id *)
2424+ | AdditionRef of user_defined_addition (** A SPDX user defined addition reference *)
2525+2626+(** license-expression *)
2727+type t =
2828+ | Simple of simple_license (** simple-expression *)
2929+ | WITH of simple_license * addition (** simple-expression "WITH" addition-expression *)
3030+ | AND of t * t (** compound-expression "AND" compound-expression *)
3131+ | OR of t * t (** compound-expression "OR" compound-expression *)
3232+3333+(** The errors returned by the parser *)
3434+type error = [
3535+ | `InvalidLicenseID of string
3636+ | `InvalidExceptionID of string
3737+ | `ParseError
3838+]
3939+4040+val parse : string -> (t, [> error]) result
4141+(** [parse str] parses [str] according to the syntax described in:
4242+ https://spdx.github.io/spdx-spec/v3.0.1/annexes/spdx-license-expressions/ *)
4343+4444+val to_string : t -> string
4545+(** [to_string license] returns a normalized string corresponding to [license]
4646+ in a valid SPDX license expression format. *)
4747+4848+val valid_license_ids : string list
4949+(** [valid_license_ids] gives the list of valid license IDs.
5050+ The list does not contain deprecated licenses.
5151+ See: https://spdx.org/licenses/ *)
5252+5353+val valid_exception_ids : string list
5454+(** [valid_exception_ids] gives the list of valid exception IDs.
5555+ The list does not contain deprecated exceptions.
5656+ See: https://spdx.org/licenses/exceptions-index.html *)
+26
vendor/opam/spdx_licenses/src/types.mli
···11+(* SPDX-License-Identifier: MIT *)
22+33+type user_defined_license = {
44+ document_ref : string option;
55+ license_ref : string;
66+}
77+88+type simple_license =
99+ | LicenseID of string
1010+ | LicenseIDPlus of string
1111+ | LicenseRef of user_defined_license
1212+1313+type user_defined_addition = {
1414+ document_ref : string option;
1515+ addition_ref : string;
1616+}
1717+1818+type addition =
1919+ | Exception of string
2020+ | AdditionRef of user_defined_addition
2121+2222+type t =
2323+ | Simple of simple_license
2424+ | WITH of simple_license * addition
2525+ | AND of t * t
2626+ | OR of t * t
···11+open Spdx_licenses
22+33+let fmt = Printf.sprintf
44+55+let pp = function
66+ | Ok x -> fmt "Ok (%s)" (to_string x)
77+ | Error `ParseError -> "Error `ParseError"
88+ | Error (`InvalidLicenseID id) -> fmt "Error (`InvalidLicenseID %s)" id
99+ | Error (`InvalidExceptionID id) -> fmt "Error (`InvalidExceptionID %s)" id
1010+1111+let test_bool name v =
1212+ Alcotest.test_case name `Quick (fun () -> Alcotest.(check bool) name v true)
1313+1414+let test name v x =
1515+ Alcotest.test_case name `Quick
1616+ (fun () -> Alcotest.(check string) name (pp v) x)
1717+1818+let () =
1919+ Alcotest.run "Tests" [
2020+ "tests", [
2121+ test_bool "valid_license_ids is reasonable"
2222+ (List.mem "MIT" valid_license_ids);
2323+ test_bool "valid_exception_ids is reasonable"
2424+ (List.mem "OCaml-LGPL-linking-exception" valid_exception_ids);
2525+ test "parse fails on invalid licenses"
2626+ (parse "TEST")
2727+ "Error (`InvalidLicenseID TEST)";
2828+ test "parse fails on invalid exceptions"
2929+ (parse "MIT WITH TEST")
3030+ "Error (`InvalidExceptionID TEST)";
3131+ test "parse has the right precedence rule (short)"
3232+ (parse "LGPL-2.1-only OR BSD-3-Clause AND MIT")
3333+ "Ok (LGPL-2.1-only OR (BSD-3-Clause AND MIT))";
3434+ test "parse has the right precedence rule (long)"
3535+ (parse "LGPL-2.1-only WITH OCaml-LGPL-linking-exception
3636+ OR BSD-3-Clause AND MIT AND ISC AND BitTorrent-1.1 OR
3737+ BSL-1.0 OR CC-BY-1.0 OR CC-BY-2.5 AND
3838+ MPL-2.0 AND 0BSD WITH OCaml-LGPL-Linking-exception")
3939+ "Ok (LGPL-2.1-only WITH OCaml-LGPL-linking-exception OR \
4040+ (BSD-3-Clause AND MIT AND ISC AND BitTorrent-1.1) OR \
4141+ BSL-1.0 OR CC-BY-1.0 OR \
4242+ (CC-BY-2.5 AND MPL-2.0 AND 0BSD WITH OCaml-LGPL-linking-exception))";
4343+ test "parse has the right precedence rule (long, reversed)"
4444+ (parse "LGPL-2.1-only WITH OCaml-LGPL-linking-exception
4545+ AND BSD-3-Clause OR MIT OR ISC OR BitTorrent-1.1 AND
4646+ BSL-1.0 AND CC-BY-1.0 AND CC-BY-2.5 OR
4747+ MPL-2.0 OR 0BSD WITH OCaml-LGPL-Linking-exception")
4848+ "Ok ((LGPL-2.1-only WITH OCaml-LGPL-linking-exception AND BSD-3-Clause) OR \
4949+ MIT OR ISC OR (BitTorrent-1.1 AND BSL-1.0 AND CC-BY-1.0 AND CC-BY-2.5) OR \
5050+ MPL-2.0 OR 0BSD WITH OCaml-LGPL-linking-exception)";
5151+ test "parse has the right case sensitivity"
5252+ (parse "BsD-2-clAUsE")
5353+ "Ok (BSD-2-Clause)";
5454+ test "make sure lower-case AND works"
5555+ (parse "MIT and BSD-2-Clause")
5656+ "Ok (MIT AND BSD-2-Clause)";
5757+ test "make sure lower-case OR works"
5858+ (parse "MIT or BSD-2-Clause")
5959+ "Ok (MIT OR BSD-2-Clause)";
6060+ test "make sure lower-case WITH works"
6161+ (parse "MIT with OCaml-LGPL-linking-exception")
6262+ "Ok (MIT WITH OCaml-LGPL-linking-exception)";
6363+ test "parse custom additions"
6464+ (parse "MIT WITH AdditionRef-MyException")
6565+ "Ok (MIT WITH AdditionRef-MyException)";
6666+ test "parse custom additions"
6767+ (parse "MIT WITH AdditionRef-MyException")
6868+ "Ok (MIT WITH AdditionRef-MyException)";
6969+ ]
7070+ ]