package liquidsoap-lang
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Liquidsoap language library
Install
dune-project
Dependency
Authors
Maintainers
Sources
liquidsoap-2.4.6.tar.gz
md5=2734fcfd41ad76ad3b6b4ba85d2ba673
sha512=d59b5d91599c7dbdac89a5985945f1f1e999a5e2468318e4f6ecca00ebe5d37ffd7eac6347316f31d647347793fc9f91fc0fb6aba255b5377d0cd8ff522d1f62
doc/src/liquidsoap-lang/parser_helper.ml.html
Source file parser_helper.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158(***************************************************************************** Liquidsoap, a programmable stream generator. Copyright 2003-2026 Savonet team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, fully stated in the COPYING file at the root of the liquidsoap distribution. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************) (** Helper functions for the parser. *) open Parsed_term module Term = Parsed_term module Vars = Term_base.Vars type arglist = Parsed_term.fun_arg list type pos = Parsed_term.pos type lexer_let_decoration = [ `None | `Recursive | `Replaces | `Eval | `Json_parse | `Yaml_parse | `Xml_parse | `Sqlite_row | `Sqlite_query ] type explicit_binding = [ `Def of Term._let | `Let of Term._let ] type binding = [ explicit_binding | `Binding of Term._let ] let render_string_ref = ref (fun ~pos:_ _ -> assert false) (* This is filled by Lexer to make it possible to use this function in the parser. *) let render_string ~pos s = let fn = !render_string_ref in fn ~pos s let pending_comments = ref [] let clear_comments () = pending_comments := [] let append_comment ~pos c = let comments = List.map String.trim (String.split_on_char '\n' c) in pending_comments := (pos, comments) :: !pending_comments let comment_distance term_pos comment_pos = if (fst comment_pos).Lexing.pos_lnum = (snd term_pos).Lexing.pos_lnum then (`Before, 0) else ( let before_distance = (fst term_pos).Lexing.pos_lnum - (snd comment_pos).Lexing.pos_lnum in let after_distance = (fst comment_pos).Lexing.pos_lnum - (snd term_pos).Lexing.pos_lnum in if 0 <= after_distance && (before_distance < 0 || after_distance < before_distance) then (`After, after_distance) else (`Before, before_distance)) let sort_comments comments = List.sort (fun (p, _) (p', _) -> Stdlib.compare (fst p).Lexing.pos_cnum (fst p').Lexing.pos_cnum) comments let attach_comments term = List.iter (fun (comment_pos, c) -> let closest_term = ref term in let distance = ref (comment_distance term.pos comment_pos) in Parsed_term.iter_term (fun term -> match (comment_distance term.pos comment_pos, !distance) with | (t, d), (t', d') when 0 <= d && (d' < 0 || if t = `Before && t' = `After then d <= d' else d < d' ) -> distance := (t, d); closest_term := term | _ -> ()) term; let comment = match !distance with `Before, _ -> `Before c | `After, _ -> `After c in !closest_term.comments <- sort_comments ((comment_pos, comment) :: !closest_term.comments)) !pending_comments; pending_comments := [] let let_args ~decoration ~pat ?arglist ~def ?cast () = { decoration; pat; arglist; def; cast } let mk_json_assoc_object_ty ~pos = function | `Tuple [`Named "string"; ty], "as", "json", "object" -> `Json_object ty | _ -> raise (Term_base.Parse_error (pos, "Invalid type constructor")) type let_opt_el = string * Term.t let let_decoration_of_lexer_let_decoration = function | `Json_parse -> `Json_parse [] | `Yaml_parse -> `Yaml_parse | `Xml_parse -> `Xml_parse | `Sqlite_query -> `Sqlite_query | `Sqlite_row -> `Sqlite_row | `Eval -> `Eval | `Recursive -> `Recursive | `None -> `None | `Replaces -> `Replaces let args_of_json_parse ~pos = function | [] -> [] | [("json5", v)] -> [("json5", v)] | (lbl, _) :: _ -> raise (Term_base.Parse_error (pos, "Invalid argument " ^ lbl ^ " for json.parse let constructor")) let mk = Parsed_term.make let mk_fun ~pos arguments body = mk ~pos (`Fun (arguments, body)) let mk_try ?ensure ?handler ?errors_list ~variable ~body ~pos () = mk ~pos (`Try { try_body = body; try_variable = variable; try_errors_list = errors_list; try_handler = handler; try_finally = ensure; }) let mk_let ~pos _let body = let ast = match _let with | `Let v -> `Let (v, body) | `Def v -> `Def (v, body) | `Binding v -> `Binding (v, body) in mk ~pos ast let mk_encoder ~pos e p = mk ~pos (`Encoder (e, p))
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>