1 Here we show the procedure to follow to add the recognition of
2 a new syntactical form.
4 Form to recognize in the model:
6 Lemma existsDec : (l:(list A)){(list_exists l)}+{~(list_exists l)}.
8 1. cd V7 ; grep "Lemma" */*.ml4
9 the result should be one or a few files. In this case the
10 only file is parsing/g_vernac.ml4. In the case of many files,
11 only one is the good one.
12 2. open the file and search for Lemma:
14 [ [ "Theorem" -> <:ast< "THEOREM" >>
15 | IDENT "Lemma" -> <:ast< "LEMMA" >>
16 | IDENT "Fact" -> <:ast< "FACT" >>
17 | IDENT "Remark" -> <:ast< "REMARK" >>
18 | IDENT "Decl" -> <:ast< "DECL" >> ] ]
20 so a Lemma is mapped into an ast of phylum thm_tok.
21 Let's search for thm_tok. Many occurrences are found,
22 but the only one that matches the form to recognize is
25 (* Definition, Goal *)
26 [ [ thm = thm_tok; id = identarg; ":"; c = constrarg ->
27 <:ast< (StartProof $thm $id $c) >>
29 So the ast created is tagged StartProof
30 3. grep "StartProof" */*.ml (usually toplevel/...)
31 Open the file and search for StartProof.
36 | [VARG_STRING kind;VARG_IDENTIFIER s;VARG_CONSTR com] ->
38 4. edit xmltheoryentries.ml and copy the entry for another rule,
39 substituting StartProof as the parameter for set_hook and
40 using the above match (with V. added where appropriate) after function:
42 let module V = Vernacinterp in
45 [V.VARG_STRING kind;V.VARG_IDENTIFIER s;V.VARG_CONSTR com] ->
51 Finally, write OCaml code to print to XML the availables interesting
52 infos. In our case the code becomes
54 let module V = Vernacinterp in
57 [V.VARG_STRING kind;V.VARG_IDENTIFIER s;V.VARG_CONSTR com] ->
61 ["uri", Names.string_of_id s ^ ".con"; "as",kind]
67 IXml.output should always be present and the code inside
68 (that is simply XML written in OCaml form) should be changed.
70 Xml.xml_empty "name" ["att1","value1" ; ... ; "attn","valuen"]
71 to create an empty element name with attributes att1 ... attn.
72 To create a non-empty element, use
73 Xml.xml_nempty "name" ["att1","value1" ; ... ; "attn","valuen"]
75 where stream is an OCaml stream of other XML elements, as:
76 * another Xml.xml_nempty
78 * [< stream1 ; ... ; streamk >]