Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 100 lines (73 sloc) 2.486 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 Common tools for LangAst modules.
20 @author Mathieu Barbin
21 *)
22
23 (** {6 Positions} *)
24
25 (**
26 If you ast follows the guidelines about positions,
27 you can use this functions.
28
29 The AST should be define with the pos in position 0,
30 in each case of the sum.
31
32 AST following this guidelines are :
33 + BslTypes.t
34 + QmlTopValue.t
35
36 If your ast comports also annotation, you can use functions
37 defined in module [Annot].
38 *)
39 (** *)
40 type pos = FilePos.pos
41 (** *)
42 val pos : 'a -> pos
43 val reset_pos : 'a -> pos -> 'a
44 val merge_pos : 'a -> pos -> 'a
45
46 (** {6 Pattern Matching on AST} *)
47
48 (**
49 You should provide in comments just near the AST definition,
50 for each sum type with several constructor a template for
51 matching the AST, with choosen names, on verbose, and one short.
52
53 You should try to update old code step by step,
54 but you MUST respect this in new code.
55
56 AST following this guidelines are :
57 + BslTypes.t
58 + QmlTopValue.t
59 *)
60
61 (**
62 {6 Guidelines. Request for comments and contributions.}
63
64 Whenever you encounter a bad case where guidelines are not
65 so easy to follow, use your imagination to find something cool :)
66 to apply instead, and maybe add a remark there.
67
68 {9 Variable Names}
69
70 If you variable has the type of a named type, it should be called
71 like the type.
72
73 [ty], [expr], [code_elt], [code], etc....
74
75 hd, tl
76
77 Collections rules for name :
78
79 x list : x -> x_list or xs
80 x map : x -> x_map, or xs
81 x set : x -> x_set, or xs
82
83 + const : [k]
84 + ident : [id]
85 + field : [fd]
86 + formatter : [fmt]
87 + param : [pm]
88 + pos : [p]
89
90 e.g.
91
92 a list of field, shorter ==> fds
93 a map of (ident list) ==> ids_map
94
95 Printers : pp
96
97 Avoid too short names for large scope.
98 The length of the variable is often proportional to the size of its scope.
99 *)
Something went wrong with that request. Please try again.