Source

ocaml-pkgbuild / pbparams.ml

module Pbparams =
  struct
    type t = PString of string | PArray of string list

    let param_values : (string * t) list ref = ref []

    let prepend_value pname newval =
      param_values := (pname, newval) :: !param_values ; ()

    let assign_string pname strval =
      prepend_value pname (PString strval)

    let assign_array pname strlist =
      prepend_value pname (PArray strlist)

    let array_elem param idx =
      match param with
        PString(str) -> if idx > 0 then 

    let param_array pname =
      match List.assoc pname !param_values with
        PString(str)    -> [ str ]
      | PArray(strlist) -> strlist

    let param_string pname =
      match List.assoc pname !param_values with
        PString(str)    -> str
      | PArray(strlist) -> String.concat " " strlist

    let list unit = List.rev !param_values

    let reset unit =
      param_values := [] ; ()
  end

let string_of_param pbv =
  match pbv with
    Pbparams.PString(str) -> "'" ^ str ^ "'"
  | Pbparams.PArray(strlist) ->
      "(" ^
      (String.concat " "
         (List.map (fun str -> "'" ^ str ^ "'") strlist))
      ^ ")"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.