diff options
| author | letouzey | 2009-07-20 13:03:25 +0000 |
|---|---|---|
| committer | letouzey | 2009-07-20 13:03:25 +0000 |
| commit | 45b27e6f0a304cfd8fee31e901151c6ed7bac1bf (patch) | |
| tree | c989a305fe6877d1753bb9f649f0a0a741b14414 /lib | |
| parent | 54861297c8f837cc7617b52737811c30356b6ad7 (diff) | |
Use camlp4 to accept some specific non-exhaustive patterns in groebner
The camlp4 extension "refutpat" provides a syntax let* for pattern
that are non-exhaustive on purpose (e.g. let* x::l = foo in ...).
A Failure is raised if the pattern doesn't match the expression.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@12245 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/refutpat.ml4 | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/refutpat.ml4 b/lib/refutpat.ml4 new file mode 100644 index 0000000000..f2575def43 --- /dev/null +++ b/lib/refutpat.ml4 @@ -0,0 +1,33 @@ +(************************************************************************) +(* v * The Coq Proof Assistant / The Coq Development Team *) +(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *) +(* \VV/ **************************************************************) +(* // * This file is distributed under the terms of the *) +(* * GNU Lesser General Public License Version 2.1 *) +(************************************************************************) + +(*i camlp4use: "pa_extend.cmo q_MLast.cmo" i*) + +open Pcaml + +(** * Non-irrefutable patterns + + This small camlp4 extension creates a "let*" variant of the "let" + syntax that allow the use of a non-exhaustive pattern. The typical + usage is: + + let* x::l = foo in ... + + when foo is already known to be non-empty. This way, no warnings by ocamlc. + A Failure is raised if the pattern doesn't match the expression. +*) + + +EXTEND + expr: + [[ "let"; "*"; p = patt; "="; e1 = expr; "in"; e2 = expr -> + <:expr< match $e1$ with + [ $p$ -> $e2$ + | _ -> failwith "Refutable pattern failed" + ] >> ]]; +END |
