package merlin-lib
Merlin's libraries
Install
Dune Dependency
Authors
Maintainers
Sources
merlin-5.5-503.tbz
sha256=67da3b34f2fea07678267309f61da4a2c6f08298de0dc59655b8d30fd8269af1
sha512=1fb3b5180d36aa82b82a319e15b743b802b6888f0dc67645baafdb4e18dfc23a7b90064ec9bc42f7424061cf8cde7f8839178d8a8537bf4596759f3ff4891873
doc/src/merlin-lib.kernel/mreader_explain.ml.html
Source file mreader_explain.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
open Parser_raw open MenhirInterpreter let opening (type a) : a terminal -> string option = function | T_STRUCT -> Some "struct" | T_SIG -> Some "sig" | T_OBJECT -> Some "object" | T_BEGIN -> Some "begin" | T_LPAREN -> Some "(" | T_LBRACKET -> Some "[" | T_LBRACE -> Some "{" | T_LBRACKETBAR -> Some "[|" | T_LBRACKETLESS -> Some "[<" | T_LBRACELESS -> Some "{<" | _ -> None let opening_st st = match incoming_symbol st with | T term -> opening term | _ -> None let closing (type a) : a terminal -> bool = function | T_END -> true | T_RPAREN -> true | T_RBRACKET -> true | T_RBRACE -> true | T_BARRBRACKET -> true | T_GREATERRBRACE -> true | T_GREATERRBRACKET -> true | _ -> false let closing_st st = match incoming_symbol st with | T term -> closing term | _ -> false type explanation = { item : (string * Location.t) option; unclosed : (string * Location.t) option; location : Location.t; popped : MenhirInterpreter.xsymbol list; shifted : MenhirInterpreter.xsymbol option; unexpected : MenhirInterpreter.token } let explain env (unexpected, startp, endp) popped shifted = let mkloc s e = { Location.loc_start = s; loc_end = e; loc_ghost = false } in let open MenhirInterpreter in let location = mkloc startp endp in let closed = ref 0 in let unclosed = ref None in let return item = { item; unclosed = !unclosed; location; popped; shifted; unexpected } in let rec process env = match top env with | None -> return None | Some (Element (st, _, startp, endp)) -> ( if closing_st st then incr closed; begin match opening_st st with | None -> () | Some st -> if !closed = 0 && !unclosed = None then unclosed := Some (st, mkloc startp endp) else decr closed end; match Parser_explain.named_item_at (number st) with | name -> return (Some (name, mkloc startp endp)) | exception Not_found -> ( match pop env with | None -> return None | Some env -> process env)) in process env let to_error { item; unclosed; location; popped; shifted; unexpected = _ } = let inside = match item with | None -> "" | Some (name, _) -> " inside `" ^ name ^ "'" in let after = match unclosed with | None -> "" | Some (name, _) -> " after unclosed " ^ name in let friendly_name sym = match sym with | X (T _) -> "`" ^ Parser_printer.print_symbol sym ^ "'" | X (N _) -> Parser_printer.print_symbol sym in let popped = String.concat " " (List.rev_map friendly_name popped) in let expecting = match shifted with | None -> if popped = "" then "" else ", maybe remove " ^ popped | Some (X (T T_EOF)) -> "" | Some sym -> if popped = "" then ", expecting " ^ friendly_name sym else ", maybe replace " ^ popped ^ " by " ^ friendly_name sym in let msg = Printf.sprintf "Syntax error%s%s%s" inside after expecting in Location.error ~loc:location ~source:Location.Parser msg exception Syntax_explanation of explanation let syntax_explanation = function | Syntax_explanation explanation -> Some (to_error explanation) | _ -> None let () = Location.register_error_of_exn syntax_explanation
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>