package reason
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>
Reason: Syntax & Toolchain for OCaml
Install
dune-project
Dependency
Authors
Maintainers
Sources
reason-3.17.2.tbz
sha256=7f4087016e8c393a13d57b7737677bc1dbf16978fd43c19354d4d79a794c8c47
sha512=3d3015d25bce329fbee9cef9b114831e7db1c10e19a26cbcaa27948c376bff3518b9d56fda9091c6df887df9ee8c33f45e1071e87933de79d65bcbf58c93cb17
doc/src/reason.refmt-lib/reason_interface_printer.ml.html
Source file reason_interface_printer.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 98open Reason open Ppxlib type t = Parsetree.signature let err = Printer_maker.err (* Note: filename should only be used with .mli files. See reason_toolchain. *) let defaultInterfaceParserFor use_stdin filename = let open Reason_toolchain in let theParser, parsedAsML = if Filename.check_suffix filename ".rei" then RE.interface_with_comments, false else if Filename.check_suffix filename ".mli" then ML.interface_with_comments, true else err ("Cannot determine default interface parser for filename '" ^ filename ^ "'.") in let ast, comments = theParser (setup_lexbuf ~use_stdin filename) in { Printer_maker.ast ; comments ; parsed_as_ml = parsedAsML ; parsed_as_intf = true } let parse ~use_stdin filetype filename = let { Printer_maker.ast ; comments ; parsed_as_ml = parsedAsML ; parsed_as_intf = parsedAsInterface } = match filetype with | `Auto -> defaultInterfaceParserFor use_stdin filename | `BinaryReason -> Printer_maker.reasonBinaryParser use_stdin filename | `Binary -> Printer_maker.ocamlBinaryParser use_stdin filename | `ML -> let lexbuf = Reason_toolchain.setup_lexbuf ~use_stdin filename in let intf = Reason_toolchain.ML.interface_with_comments in let ast, comments = intf lexbuf in { ast; comments; parsed_as_ml = true; parsed_as_intf = true } | `Reason -> let lexbuf = Reason_toolchain.setup_lexbuf ~use_stdin filename in let intf = Reason_toolchain.RE.interface_with_comments in let ast, comments = intf lexbuf in { ast; comments; parsed_as_ml = false; parsed_as_intf = true } in if not parsedAsInterface then err "The file parsed does not appear to be an interface file." else (ast, comments), parsedAsML let print printtype filename parsedAsML output_chan output_formatter = match printtype with | `BinaryReason -> fun (ast, comments) -> (* Our special format for interchange between reason should keep the * comments separate. This is not compatible for input into the * ocaml compiler - only for input into another version of Reason. We * also store whether or not the binary was originally *parsed* as an * interface file. *) output_value output_chan ( Ocaml_common.Config.ast_intf_magic_number , filename , ast , comments , parsedAsML , true ) | `Binary -> fun (ast, _) -> let ast = ast |> Reason_syntax_util.( apply_mapper_to_signature remove_stylistic_attrs_mapper) |> Reason_syntax_util.(apply_mapper_to_signature backport_letopt_mapper) in Ppxlib__.Utils.Ast_io.write output_chan { Ppxlib__.Utils.Ast_io.input_name = filename ; input_version = Obj.magic (module Ppxlib_ast.Compiler_version : Ppxlib_ast.OCaml_version) ; ast = Intf ast } ~add_ppx_context:false | `AST -> fun (ast, _) -> Ocaml_common.Printast.interface output_formatter (Reason_toolchain.To_current.copy_signature ast) | `None -> fun _ -> () | `ML -> Reason_toolchain.ML.print_interface_with_comments output_formatter | `Reason -> Reason_toolchain.RE.print_interface_with_comments output_formatter
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>