Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 98 lines (74 sloc) 3.149 kb
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18 (**
19 High-level interface to the opa parser.
20 *)
21
22 (**
23 This module defines a higher-level interface for calling the trx opa parser.
24 It defines as well utils using cache, and reports errors using located messages.
25 *)
26
27 (** {6 Types Alias} *)
28
29 (**
30 Just for clarty, to avoid confusion between filenames, contents, etc...
31 *)
32 type filename = string
33 type contents = string
34
35 type nonuid = SurfaceAst.nonuid
36
37 (** {6 Meta-informations} *)
38
39 (**
40 Hash of all trx, ml and mli use to generate the parser
41 Currently : general/surfaceAst.ml and passes/syntax/*.{trx,ml}.
42 Used in particular to know if the cache are relevant from a compilation
43 of the compiler to an other.
44 *)
45 val hash : string
46
47 (** {6 Low-Level Parsing} *)
48
49 (**
50 These function are just a call to the trx parser.
51 They may raise [Trx_runtime.SyntaxError].
52 [ll_] stands for [low_level].
53
54 The given filename is optional, and given to trx, used for errors messages only.
55 *)
56
57 val ll_expr : ?filename:filename -> contents -> (nonuid, SurfaceAst.parsing_directive) SurfaceAst.expr
58 val ll_ty : ?filename:filename -> contents -> nonuid SurfaceAst.ty
59 val ll_code : ?filename:filename -> contents -> (nonuid, SurfaceAst.parsing_directive) SurfaceAst.code
60
61 (** {6 High-level Parsing} *)
62
63 (**
64 These function catch the trx runtime error and print a citation of the source,
65 before exiting using the function [error] (TODO: use OManager).
66 *)
67
68 val expr : ?filename:filename -> contents -> (nonuid, SurfaceAst.parsing_directive) SurfaceAst.expr
69 val ty : ?filename:filename -> contents -> nonuid SurfaceAst.ty
70
71 (**
72 Used with [cache:true], the function will set/get a cache of the parsed AST from
73 [{mlstate_dir}/opa/cache/parser].
74 (Default is [cache:false])
75 *)
484403b @OpaOnWindowsNow [fix] syntaxHelper: add verification step of produced code
OpaOnWindowsNow authored
76 val code : ?parser_:OpaSyntax.t -> ?cache:bool -> ?filename:filename -> contents -> (nonuid, SurfaceAst.parsing_directive) SurfaceAst.code
fccc685 Initial open-source release
MLstate authored
77
78 (** {6 Deprecated API} *)
79
80 (**
81 The rest of the API was done before the introduction of guidelines.
82 Please do not use in new code.
83 *)
84
85 exception Specific_parse_error of (FilePos.pos * string)
86
87 exception No_such_file of string
88
89 (**
90 [parse_file filename]
91 Read the file corresponding to the given filename and parse it
92 @param filename The name of the file to be parsed
93 @raise Trx_runtime.SyntaxError see above
94 @raise Trx_runtime.ExceptionDuringParsing see above
95 @raise No_such_file The given filename cannot be read
96 *)
97 val parse_file : filename -> (string,SurfaceAst.parsing_directive) SurfaceAst.code
Something went wrong with that request. Please try again.