From fc06cb87286e2b114c7f92500511d5914b8f7f48 Mon Sep 17 00:00:00 2001 From: herbelin Date: Thu, 22 Jul 2010 21:06:18 +0000 Subject: Extension of the recursive notations mechanism - Added support for recursive notations with binders - Added support for arbitrary large iterators in recursive notations - More checks on the use of variables and improved error messages - Do side-effects in metasyntax only when sure that everything is ok - Documentation Note: it seems there were a small bug in match_alist (instances obtained from matching the first copy of iterator were not propagated). git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@13316 85f007b7-540e-0410-9357-904b9bb8a0f7 --- doc/refman/RefMan-syn.tex | 165 +++++++----- interp/constrextern.ml | 53 ++-- interp/constrintern.ml | 277 +++++++++++++------- interp/constrintern.mli | 10 +- interp/implicit_quantifiers.ml | 4 +- interp/notation.ml | 3 +- interp/ppextend.ml | 1 + interp/ppextend.mli | 1 + interp/syntax_def.ml | 4 +- interp/topconstr.ml | 540 ++++++++++++++++++++++++++------------- interp/topconstr.mli | 66 +++-- parsing/egrammar.ml | 58 +++-- parsing/egrammar.mli | 12 +- parsing/extend.ml | 4 +- parsing/extend.mli | 2 + parsing/g_constr.ml4 | 24 +- parsing/g_vernac.ml4 | 2 + parsing/pcoq.ml4 | 28 +- parsing/pcoq.mli | 4 +- parsing/ppconstr.ml | 38 +-- parsing/ppvernac.ml | 4 +- parsing/q_coqast.ml4 | 7 +- plugins/subtac/subtac_cases.ml | 6 +- pretyping/cases.ml | 4 +- pretyping/detyping.ml | 2 + pretyping/rawterm.ml | 32 ++- pretyping/rawterm.mli | 4 +- test-suite/csdp.cache | Bin 44878 -> 45137 bytes test-suite/output/Notations.out | 28 ++ test-suite/output/Notations.v | 39 +++ test-suite/output/Notations2.out | 15 ++ test-suite/output/Notations2.v | 41 +++ toplevel/metasyntax.ml | 266 ++++++++++++------- toplevel/vernacentries.ml | 2 +- 34 files changed, 1194 insertions(+), 552 deletions(-) diff --git a/doc/refman/RefMan-syn.tex b/doc/refman/RefMan-syn.tex index 6b471ec392..f5c3dfcaff 100644 --- a/doc/refman/RefMan-syn.tex +++ b/doc/refman/RefMan-syn.tex @@ -474,6 +474,8 @@ Locate "'exists' _ , _". & $|$ & {\tt right associativity} \\ & $|$ & {\tt no associativity} \\ & $|$ & {\ident} {\tt ident} \\ + & $|$ & {\ident} {\tt binder} \\ + & $|$ & {\ident} {\tt closed binder} \\ & $|$ & {\ident} {\tt global} \\ & $|$ & {\ident} {\tt bigint} \\ & $|$ & {\tt only parsing} \\ @@ -485,69 +487,7 @@ Locate "'exists' _ , _". \label{notation-syntax} \end{figure} -\subsection{Notations with recursive patterns} - -An experimental mechanism is provided for declaring elementary -notations including recursive patterns. The basic syntax is - -\begin{coq_eval} -Require Import List. -\end{coq_eval} - -\begin{coq_example*} -Notation "[ x ; .. ; y ]" := (cons x .. (cons y nil) ..). -\end{coq_example*} - -On the right-hand-side, an extra construction of the form {\tt ..} ($f$ -$t_1$ $\ldots$ $t_n$) {\tt ..} can be used. Notice that {\tt ..} is part of -the {\Coq} syntax while $\ldots$ is just a meta-notation of this -manual to denote a sequence of terms of arbitrary size. - -This extra construction enclosed within {\tt ..}, let's call it $t$, -must be one of the argument of an applicative term of the form {\tt -($f$ $u_1$ $\ldots$ $u_n$)}. The sequences $t_1$ $\ldots$ $t_n$ and -$u_1$ $\ldots$ $u_n$ must coincide everywhere but in two places. In -one place, say the terms of indice $i$, we must have $u_i = t$. In the -other place, say the terms of indice $j$, both $u_j$ and $t_j$ must be -variables, say $x$ and $y$ which are bound by the notation string on -the left-hand-side of the declaration. The variables $x$ and $y$ in -the string must occur in a substring of the form "$x$ $s$ {\tt ..} $s$ -$y$" where {\tt ..} is part of the syntax and $s$ is two times the -same sequence of terminal symbols (i.e. symbols which are not -variables). - -These invariants must be satisfied in order the notation to be -correct. The term $t_i$ is the {\em terminating} expression of -the notation and the pattern {\tt ($f$ $u_1$ $\ldots$ $u_{i-1}$ {\rm [I]} -$u_{i+1}$ $\ldots$ $u_{j-1}$ {\rm [E]} $u_{j+1}$ $\ldots$ $u_{n}$)} is the -{\em iterating pattern}. The hole [I] is the {\em iterative} place -and the hole [E] is the {\em enumerating} place. Remark that if $j