@@ -51,21 +51,34 @@ module type S = sig
51
51
string -> language * file * statement list
52
52
(* * Given a filename, parse the file, and return the detected language
53
53
together with the list of statements parsed.
54
- @param language specify a language; overrides auto-detection. *)
55
54
56
- val parse_file_lazy :
57
- ?language : language ->
58
- string -> language * file * statement list Lazy .t
59
- (* * Given a filename, parse the file, and return the detected language
60
- together with the list of statements parsed.
55
+ WARNING: please note that this function makes it difficult to report
56
+ error locations, since exceptions might be raised during parsing
57
+ and any caller of this function will not have access to the [file]
58
+ return value of the function, which is necessary to correctly
59
+ interpret the locations in error exceptions. Instead, please use
60
+ either {parse_all} or {parse_input}.
61
+
61
62
@param language specify a language; overrides auto-detection. *)
62
63
63
- val parse_raw_lazy :
64
+ val parse_all :
64
65
?language : language ->
65
- filename :string -> string -> language * file * statement list Lazy .t
66
- (* * Given a filename and a string, parse the string, and return the detected
67
- language together with the list of statements parsed.
68
- @param language specify a language; overrides auto-detection. *)
66
+ [< `File of string
67
+ | `Stdin of language
68
+ | `Raw of string * language * string ] ->
69
+ language * file * statement list Lazy .t
70
+ (* * Full (but lazy) parsing of either a file (see {!parse_file}), stdin
71
+ (with given language), or some arbitrary contents, of the form
72
+ [`Raw (filename, language, contents)].
73
+ Returns a triplet [(lan, file, stmts)], containing:
74
+ - the language [lan] detected
75
+ - a [file] value that stores the metadata about file locations
76
+ - a lazy list of statements [stmts]; forcing this list will run the actual
77
+ parsing of the whole input given as argument, and may raise errors, if
78
+ any arises during the parsing (such as lexical errors, etc..)
79
+
80
+ @param language specify a language for parsing, overrides auto-detection
81
+ and stdin specification. *)
69
82
70
83
val parse_input :
71
84
?language : language ->
@@ -76,9 +89,12 @@ module type S = sig
76
89
(* * Incremental parsing of either a file (see {!parse_file}), stdin
77
90
(with given language), or some arbitrary contents, of the form
78
91
[`Raw (filename, language, contents)].
79
- Returns a triplet [(lan, gen, cl)], containing
80
- the language detexted [lan], a genratro function [gen] for parsing the input,
81
- and a cleanup function [cl] to call in order to cleanup the file descriptors.
92
+ Returns a quadruplet [(lan, file, gen, cl)], containing:
93
+ - the language [lan] detected
94
+ - a [file] value that stores the metadata about file locations
95
+ - a genrator function [gen] for parsing the input,
96
+ - a cleanup function [cl] to call in order to cleanup the file descriptors
97
+
82
98
@param language specify a language for parsing, overrides auto-detection
83
99
and stdin specification. *)
84
100
0 commit comments