1Parse(3) OCaml library Parse(3)
2
3
4
6 Parse - Entry points in the parser
7
9 Module Parse
10
12 Module Parse
13 : sig end
14
15
16 Entry points in the parser
17
18 Warning: this module is unstable and part of Compiler_libs .
19
20
21
22
23
24
25 val implementation : Lexing.lexbuf -> Parsetree.structure
26
27
28
29
30 val interface : Lexing.lexbuf -> Parsetree.signature
31
32
33
34
35 val toplevel_phrase : Lexing.lexbuf -> Parsetree.toplevel_phrase
36
37
38
39
40 val use_file : Lexing.lexbuf -> Parsetree.toplevel_phrase list
41
42
43
44
45 val core_type : Lexing.lexbuf -> Parsetree.core_type
46
47
48
49
50 val expression : Lexing.lexbuf -> Parsetree.expression
51
52
53
54
55 val pattern : Lexing.lexbuf -> Parsetree.pattern
56
57
58
59
60 val module_type : Lexing.lexbuf -> Parsetree.module_type
61
62
63
64
65 val module_expr : Lexing.lexbuf -> Parsetree.module_expr
66
67
68
69
70
71 The functions below can be used to parse Longident safely.
72
73 val longident : Lexing.lexbuf -> Longident.t
74
75 The function longident is guaranteed to parse all subclasses of Longi‐
76 dent.t used in OCaml: values, constructors, simple or extended module
77 paths, and types or module types.
78
79 However, this function accepts inputs which are not accepted by the
80 compiler, because they combine functor applications and infix opera‐
81 tors. In valid OCaml syntax, only value-level identifiers may end with
82 infix operators Foo.( + ) . Moreover, in value-level identifiers the
83 module path Foo must be simple ( M.N rather than F(X) ): functor appli‐
84 cations may only appear in type-level identifiers. As a consequence, a
85 path such as F(X).( + ) is not a valid OCaml identifier; but it is ac‐
86 cepted by this function.
87
88
89
90
91 The next functions are specialized to a subclass of Longident.t
92
93
94 val val_ident : Lexing.lexbuf -> Longident.t
95
96 This function parses a syntactically valid path for a value. For in‐
97 stance, x , M.x , and (+.) are valid. Contrarily, M.A , F(X).x , and
98 true are rejected.
99
100 Longident for OCaml's value cannot contain functor application. The
101 last component of the Longident.t is not capitalized, but can be an op‐
102 erator A.Path.To.(.%.%.(;..)<-)
103
104
105
106
107 val constr_ident : Lexing.lexbuf -> Longident.t
108
109 This function parses a syntactically valid path for a variant construc‐
110 tor. For instance, A , M.A and M.(::) are valid, but both M.a and
111 F(X).A are rejected.
112
113 Longident for OCaml's variant constructors cannot contain functor ap‐
114 plication. The last component of the Longident.t is capitalized, or it
115 may be one the special constructors: true , false , () , [] , (::) .
116 Among those special constructors, only (::) can be prefixed by a module
117 path ( A.B.C.(::) ).
118
119
120
121 val simple_module_path : Lexing.lexbuf -> Longident.t
122
123 This function parses a syntactically valid path for a module. For in‐
124 stance, A , and M.A are valid, but both M.a and F(X).A are rejected.
125
126 Longident for OCaml's module cannot contain functor application. The
127 last component of the Longident.t is capitalized.
128
129
130
131 val extended_module_path : Lexing.lexbuf -> Longident.t
132
133 This function parse syntactically valid path for an extended module.
134 For instance, A.B and F(A).B are valid. Contrarily, (.%()) or [] are
135 both rejected.
136
137 The last component of the Longident.t is capitalized.
138
139
140
141 val type_ident : Lexing.lexbuf -> Longident.t
142
143 This function parse syntactically valid path for a type or a module
144 type. For instance, A , t , M.t and F(X).t are valid. Contrarily,
145 (.%()) or [] are both rejected.
146
147 In path for type and module types, only operators and special construc‐
148 tors are rejected.
149
150
151
152
153
154OCamldoc 2022-07-22 Parse(3)