]> matita.cs.unibo.it Git - helm.git/blob - helm/software/lambda-delta/automath/autParser.mly
- we implemented the hierarchy and sort names declaration in text parser
[helm.git] / helm / software / lambda-delta / automath / autParser.mly
1 /* Copyright (C) 2000, 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://cs.unibo.it/helm/.
24  */
25
26 %{
27    module A = Aut
28
29    let debug = false
30
31    let _ = Parsing.set_trace debug
32 %}
33    %token <int> NUM
34    %token <string> IDENT
35    %token EOF MINUS PLUS TIMES AT FS CN CM SC QT TD OP CP OB CB OA CA
36    %token TYPE PROP DEF EB E PN EXIT
37     
38    %start entry
39    %type <Aut.command option * bool> entry   
40 %%
41    path: MINUS {} | FS {} ;
42    oftype: CN {} | CM {} ;
43    star: TIMES {} | AT {} ;
44    sc: E {} | SC {} | CN {} ;
45    eof: SC {} | EOF {} ;
46
47    expand:
48       |    { true  }
49       | TD { false }
50    ;
51    local:
52       |      { false }
53       | path { true  }
54    ;
55
56    idents:
57       | IDENT             { [$1]     }
58       | IDENT path idents { $1 :: $3 }
59    ;
60    qid:
61       | IDENT                    { ($1, true, [])  }
62       | IDENT QT QT              { ($1, true, [])  }
63       | IDENT QT local idents QT { ($1, $3, $4)    }
64    ;
65    term:
66       | TYPE                         { A.Sort true         }
67       | PROP                         { A.Sort false        }
68       | qid                          { A.GRef ($1, [])     }
69       | qid OP CP                    { A.GRef ($1, [])     }
70       | qid OP terms CP              { A.GRef ($1, $3)     } 
71       | OA term CA term              { A.Appl ($2, $4)     }
72       | OB IDENT oftype term CB term { A.Abst ($2, $4, $6) } 
73    ;
74    terms:
75       | term          { [$1]     }
76       | term CM terms { $1 :: $3 }
77    ;
78    
79    start:
80       | PLUS {} | MINUS {} | EXIT {} | eof {}
81       | star {} | IDENT {} | OB {} 
82    ; 
83    entity:
84       | PLUS IDENT                    { Some (A.Section (Some (true, $2)))  }
85       | PLUS TIMES IDENT              { Some (A.Section (Some (false, $3))) }
86       | MINUS IDENT                   { Some (A.Section None)               }
87       | EXIT                          { Some (A.Section None)               }
88       | star                          { Some (A.Context None)               }
89       | qid star                      { Some (A.Context (Some $1))          }
90       | IDENT DEF EB sc term          { Some (A.Block ($1, $5))             }
91       | IDENT sc term DEF EB          { Some (A.Block ($1, $3))             }
92       | OB IDENT oftype term CB       { Some (A.Block ($2, $4))             }
93       | IDENT DEF PN sc term          { Some (A.Decl ($1, $5))              }
94       | IDENT sc term DEF PN          { Some (A.Decl ($1, $3))              }
95       | IDENT DEF expand term sc term { Some (A.Def ($1, $6, $3, $4))       }
96       | IDENT sc term DEF expand term { Some (A.Def ($1, $3, $5, $6))       }
97       | eof                           { None                                }
98    ;
99    entry:
100       | entity       { $1, false }
101       | entity start { $1, true }
102