ocaml-stringpainter / src / Basic.ml

(*********************************************************************************************************************
 * Copyrights (C) by
 *  Pawel Wieczorek <wieczyk gmail>
 *
 * http://bitbucket.org/wieczyk/ocaml-stringpainter
 ********************************************************************************************************************)


include Engine

let sp_indent_when_multiline sp =
    if any_multiline sp
    then sp_indent sp
    else sp_nested sp

let sp_value_int  x = sp_value (string_of_int x)
let sp_value_bool x = sp_value (string_of_bool x)


let sp_list opening closing separator = function
    | [] -> sp_nested
        [ opening
        ; closing
        ]

    | [x] -> sp_nested
        [ opening
        ; x
        ; closing
        ]

    | x::xs -> sp_nested
        [ opening
        ; x
        ; sp_nested (List.map (fun y -> sp_nested [separator; y]) xs)
        ; closing
        ]

let sp_opening_square_bracket = sp_syntax "["
let sp_closing_square_bracket = sp_syntax "]"

let sp_opening_bracket  = sp_syntax "("
let sp_coma             = sp_syntax ","
let sp_semicolon        = sp_syntax ";"
let sp_closing_bracket  = sp_syntax ")"

let sp_std_list = sp_list sp_opening_bracket sp_closing_bracket sp_coma
let sp_ml_list  = sp_list sp_opening_square_bracket sp_closing_square_bracket sp_semicolon
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.