Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 99 lines (78 sloc) 3.432 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 This module contains the compilation passes that are executed
20 in SurfaceAst (the very front end of the compiler)
21 except the parsing pass (that is available in OpaParser)
22 *)
23
4692879 @OpaOnWindowsNow [feature] Internationalisation: add @i18n directive and start support…
OpaOnWindowsNow authored
24 open SurfaceAstPassesTypes
25 open SurfaceAst
fccc685 Initial open-source release
MLstate authored
26
27 (**
28 This pass looks for Package declaration of each file, and loads these
29 dependencies
30 The node Package is removed from the code and never appears afterwards
31 *)
32 val pass_load_objects:
33 options:options ->
34 (([< SurfaceAst.all_directives > `static_content `static_content_directory `static_resource `static_resource_directory ] as 'b) parsed_file list * 'b parsed_file list) ->
35 ((string, 'b) SurfaceAst.code_elt ObjectFiles.parsed_code -> unit) ->
36 unit
37
38 (**
39 This pass goes through the whole to transform the syntactic constructions
40 parsers and xml_parser into real opa code
41 Parser generation happens in trx_convert.ml
42 Xml_parser generation happens in xml_pattern.ml
43
44 Assumptions: no alpha renaming yet
45 no directives other than `xml_parser contains an expression in its variant
46
47 Directives removed : [\[ `xml_parser _ \]]
48
49 Directives added : [\[\]]
50 *)
51 val pass_parser_generation :
52 options:options ->
53 (string,parsing_directive) env_both_lcodes ->
54 (string, renaming_directive) env_both_lcodes
55
56
57 (**
58 This pass alpha renames the whole code
59 It takes care of renaming types, type variables, and identifiers
60
61 Assumptions:
62 - every identifier that is allowed to be unbound should be given (first argument)
63 for example, git_version, or release are defined afterwards by the compiler and must be given
64 in the list
65 - every type identifier that is allowed to be unbound should given as
66 a second argument
67 tuples are a special cases: tuple_%d, where d >= 0 is automatically defined once it is used
68 afterwards, a mapping from integers to the corresponding tuple identifier can be retrieved
69 - no directive bind variables in their subexpression, or somehow change the scope
70 there is of course a few exceptions: SurfaceAst.alpha_renaming_directive
71 - no variant of a directive contains expressions, patterns, types or anything that should be renamed
72
73 Directives removed : [SurfaceAst.alpha_renaming_directive]
74
75 Directives added : [\[ `local \]]
76 *)
77 val pass_check_duplication :
78 string list ->
79 string list ->
80 options:options ->
81 (string, renaming_directive) env_both_lcodes ->
82 (Ident.t, dependency_directive) env_both_lcodes
83
84
85 (**
86 This pass insert the definitions of tuple_%d for every use that was recorded
87 by the alpha renaming pass
88
89 Assumption: alpha renaming has been performed already
90
91 Directives removed : [\[\]]
92
93 Directives added : [\[\]]
94 *)
95 val pass_tuple_types :
96 options:options ->
97 (Ident.t, 'b) code ->
98 (Ident.t, 'b) code
Something went wrong with that request. Please try again.