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