]> matita.cs.unibo.it Git - helm.git/blob - matita/components/lexicon/cicNotation.ml
- the connections between the intermediate language and the "bag"
[helm.git] / matita / components / lexicon / cicNotation.ml
1 (* Copyright (C) 2005, HELM Team.
2  * 
3  * This file is part of HELM, an Hypertextual, Electronic
4  * Library of Mathematics, developed at the Computer Science
5  * Department, University of Bologna, Italy.
6  * 
7  * HELM is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  * 
12  * HELM is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with HELM; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20  * MA  02111-1307, USA.
21  * 
22  * For details, see the HELM World-Wide-Web page,
23  * http://helm.cs.unibo.it/
24  *)
25
26 (* $Id$ *)
27
28 open LexiconAst
29
30 class type g_status =
31  object ('self)
32   inherit Interpretations.g_status
33   inherit TermContentPres.g_status
34   inherit CicNotationParser.g_status
35  end
36
37 class status =
38  object (self)
39   inherit Interpretations.status
40   inherit TermContentPres.status
41   inherit CicNotationParser.status
42   method set_notation_status
43    : 'status. #g_status as 'status -> 'self
44       = fun o -> ((self#set_interp_status o)#set_content_pres_status o)#set_notation_parser_status o
45  end
46
47 let process_notation status st =
48   match st with
49   | Notation (loc, dir, l1, associativity, precedence, l2) ->
50       let l1 = 
51         CicNotationParser.check_l1_pattern
52          l1 (dir = Some `RightToLeft) precedence associativity
53       in
54       let status =
55         if dir <> Some `RightToLeft then
56           CicNotationParser.extend status l1 
57             (fun env loc ->
58               NotationPt.AttributedTerm
59                (`Loc loc,TermContentPres.instantiate_level2 env l2)) 
60         else status
61       in
62       let status =
63         if dir <> Some `LeftToRight then
64          let status = TermContentPres.add_pretty_printer status l2 l1 in
65           status
66         else
67           status
68       in
69        status
70   | Interpretation (loc, dsc, l2, l3) -> 
71       Interpretations.add_interpretation status dsc l2 l3
72   | st -> status
73