1Parse(3)                         OCaml library                        Parse(3)
2
3
4

NAME

6       Parse - Entry points in the parser
7

Module

9       Module   Parse
10

Documentation

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
61       The functions below can be used to parse Longident safely.
62
63       val longident : Lexing.lexbuf -> Longident.t
64
65       The  function longident is guaranteed to parse all subclasses of Longi‐
66       dent.t used in OCaml: values, constructors, simple or  extended  module
67       paths, and types or module types.
68
69       However,  this  function  accepts  inputs which are not accepted by the
70       compiler, because they combine functor applications  and  infix  opera‐
71       tors.  In valid OCaml syntax, only value-level identifiers may end with
72       infix operators Foo.( + ) .  Moreover, in value-level  identifiers  the
73       module path Foo must be simple ( M.N rather than F(X) ): functor appli‐
74       cations may only appear in type-level identifiers.  As a consequence, a
75       path  such as F(X).( + ) is not a valid OCaml identifier; but it is ac‐
76       cepted by this function.
77
78
79
80
81       The next functions are specialized to a subclass of Longident.t
82
83
84       val val_ident : Lexing.lexbuf -> Longident.t
85
86       This function parses a syntactically valid path for a  value.  For  in‐
87       stance,  x  , M.x , and (+.)  are valid. Contrarily, M.A , F(X).x , and
88       true are rejected.
89
90       Longident for OCaml's value cannot contain  functor  application.   The
91       last component of the Longident.t is not capitalized, but can be an op‐
92       erator A.Path.To.(.%.%.(;..)<-)
93
94
95
96
97       val constr_ident : Lexing.lexbuf -> Longident.t
98
99       This function parses a syntactically valid path for a variant construc‐
100       tor.   For  instance,  A  ,  M.A and M.(::) are valid, but both M.a and
101       F(X).A are rejected.
102
103       Longident for OCaml's variant constructors cannot contain  functor  ap‐
104       plication.  The last component of the Longident.t is capitalized, or it
105       may be one the special constructors: true , false , () , []  ,  (::)  .
106       Among those special constructors, only (::) can be prefixed by a module
107       path ( A.B.C.(::) ).
108
109
110
111       val simple_module_path : Lexing.lexbuf -> Longident.t
112
113       This function parses a syntactically valid path for a module.  For  in‐
114       stance, A , and M.A are valid, but both M.a and F(X).A are rejected.
115
116       Longident  for  OCaml's module cannot contain functor application.  The
117       last component of the Longident.t is capitalized.
118
119
120
121       val extended_module_path : Lexing.lexbuf -> Longident.t
122
123       This function parse syntactically valid path for  an  extended  module.
124       For  instance,  A.B  and F(A).B are valid. Contrarily, (.%()) or [] are
125       both rejected.
126
127       The last component of the Longident.t is capitalized.
128
129
130
131       val type_ident : Lexing.lexbuf -> Longident.t
132
133       This function parse syntactically valid path for a  type  or  a  module
134       type.   For  instance,  A  ,  t , M.t and F(X).t are valid. Contrarily,
135       (.%()) or [] are both rejected.
136
137       In path for type and module types, only operators and special construc‐
138       tors are rejected.
139
140
141
142
143
144OCamldoc                          2021-07-22                          Parse(3)
Impressum