diff options
author | octachron <octa@polychoron.fr> | 2016-05-05 19:50:56 +0200 |
---|---|---|
committer | Gabriel Scherer <gabriel.scherer@gmail.com> | 2016-05-09 09:35:05 -0400 |
commit | 96806cf63356d6577c4c3faef60ba62cd72ea158 (patch) | |
tree | 9c07e2df0244f2ed13051339252efbdf52ae2295 /parsing/depend.ml | |
parent | 6712be88f08d44ed81ffa9d0805a1372cf3447ea (diff) | |
download | ocaml-96806cf63356d6577c4c3faef60ba62cd72ea158.tar.gz |
GPR#187: local open for patterns
This commits extends the pattern syntax to support local open in
patterns. Four new constructions mirroring the expression constructions
are added
* `M.(pattern)`
* `M.[pattern_list]` ⟺ M.([pattern_list])
* `M.{labeled_pattern_list}` ⟺ M.({label_pattern_list})
* `M.[| .. |] ⟺ M.( [| .. |] )
At the typing phase, the construction `M.(pattern)` brings all
identifiers defined within M inside the scope and then proceed with the
typing of `pattern`. All others constructions are desugared to the
`M.(..)` construction during parsing.
Questionable implementation details:
* Currently, the local pattern open use the `type_open` function like
the local expression pattern. However, this implies that values defined
inside `M` are also brought to the scope. A specialized
`type_open_for_pattern` would be more efficient.
Diffstat (limited to 'parsing/depend.ml')
-rw-r--r-- | parsing/depend.ml | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/parsing/depend.ml b/parsing/depend.ml index 43a139b2ac..8703ffe019 100644 --- a/parsing/depend.ml +++ b/parsing/depend.ml @@ -200,6 +200,7 @@ let rec add_pattern bv pat = | Ppat_type li -> add bv li | Ppat_lazy p -> add_pattern bv p | Ppat_unpack id -> pattern_bv := StringMap.add id.txt bound !pattern_bv + | Ppat_open ( m, p) -> let bv = open_module bv m.txt in add_pattern bv p | Ppat_exception p -> add_pattern bv p | Ppat_extension e -> handle_extension e |