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