/* Copyright (C) 2000, HELM Team. * * This file is part of HELM, an Hypertextual, Electronic * Library of Mathematics, developed at the Computer Science * Department, University of Bologna, Italy. * * HELM is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * HELM is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HELM; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, * MA 02111-1307, USA. * * For details, see the HELM World-Wide-Web page, * http://cs.unibo.it/helm/. */ %{ module G = Options module N = Layer module T = Txt IFDEF PARSER THEN let _ = Parsing.set_trace !G.debug_parser END %} %token IX %token ID STR %token OP CP OB CB OA CA OC CC FS CN CM EQ STAR HASH TE CT %token GRAPH MAIN DECL AX CONG DEF TH GEN REQ OPEN CLOSE SORTS EOF %start entry %type entry %% hash: | {} | HASH {} ; fs: | {} | FS {} ; main: | { false } | MAIN { true } ; comment: | { "", "" } | STR { "", $1 } | STR STR { $1, $2 } ; ids: | ID { [$1] } | ID CM ids { $1 :: $3 } ; sort: | ID { None, $1 } | IX ID { Some $1, $2 } ; sorts: | sort { [$1] } | sort CM sorts { $1 :: $3 } ; layer: | { N.infinity } | CT IX { N.finite $2 } ; binder: | OB ID CN term CB layer { T.Abst ($6, $2, true, $4) } | OB term CB layer { T.Abst ($4, "", false, $2) } | OB ID TE term CB layer { T.Abst ($6, $2, false, $4) } | OB ID EQ term CB { T.Abbr ($2, $4) } ; binders: | binder fs binder { [$1; $3] } | binder fs binders { $1 :: $3 } ; lenv: | binder { [$1] } | OC binders CC { $2 } ; atom: | STAR IX { T.Sort $2 } | STAR ID { T.NSrt $2 } | hash IX { T.LRef $2 } | ID { T.NRef $1 } | HASH ID { T.NRef $2 } | atom OP terms CP { T.Inst ($1, $3) } ; term: | atom { $1 } | OA term CA fs term { T.Cast ($2, $5) } | OP term CP fs term { T.Appl ($2, $5) } | lenv fs term { T.Proj ($1, $3) } | OP term CP { $2 } ; terms: | term { [$1] } | term CM terms { $1 :: $3 } ; decl: | DECL { T.Decl } | AX { T.Ax } | CONG { T.Cong } ; def: | DEF { T.Def } | TH { T.Th } ; command: | GRAPH ID { T.Graph $2 } | main decl comment ID CN term { T.Constant ($1, $2, $4, $3, $6) } | main def comment ID EQ term { T.Constant ($1, $2, $4, $3, $6) } | main def comment ID EQ term CN term { T.Constant ($1, $2, $4, $3, T.Cast ($8, $6)) } | GEN terms { T.Generate $2 } | REQ ids { T.Require $2 } | OPEN ID { T.Section (Some $2) } | CLOSE { T.Section None } | SORTS sorts { T.Sorts $2 } ; start: | GRAPH {} | decl {} | def {} | GEN {} | | REQ {} | OPEN {} | CLOSE {} | SORTS {} | EOF {} ; entry: | command start { Some $1 } | EOF { None } ;