2 * Copyright (C) 2019 Richard W.M. Jones
3 * Copyright (C) 2019 Red Hat Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
25 %token <Ast.substs> CODE
37 %token <Ast.substs> STRING
38 %token <string> TACTIC
41 (* Start nonterminals. *)
43 %start <Ast.expr> expr
53 fun env (name, expr) -> Ast.Env.add name expr env
58 | option(goal_stmt) patterns COLON barelist option(CODE)
62 sprintf "_goal@%d" $startpos.pos_lnum, []
64 name, Ast.EGoal ($loc, (params, $2, $4, $5))
68 let name, params = $1 in
69 name, Ast.EGoal ($loc, (params, [], [], Some $2))
71 | TACTIC_KEYWORD TACTIC params_decl EQUALS CODE
73 $2, Ast.ETactic ($loc, ($3, $5))
75 | LET ID EQUALS expr { $2, $4 }
79 | GOAL ID option(params_decl) EQUALS
80 { $2, match $3 with None -> [] | Some ps -> ps }
83 | LEFT_PAREN separated_list(COMMA, param_decl) RIGHT_PAREN { $2 }
89 | separated_list(COMMA, pattern) { $1 }
92 | STRING { Ast.PTactic ($loc, "*file", [$1]) }
93 | ID pattern_params { Ast.PTactic ($loc, $1, $2) }
96 | LEFT_PAREN separated_list(COMMA, pattern_param) RIGHT_PAREN { $2 }
103 | ID params { Ast.ECallGoal ($loc, $1, $2) }
104 | ID { Ast.EVar ($loc, $1) }
105 | TACTIC params { Ast.ECallTactic ($loc, $1, $2) }
106 | STRING { Ast.ESubsts ($loc, $1) }
107 | LEFT_ARRAY barelist RIGHT_ARRAY { Ast.EList ($loc, $2) }
110 | separated_list(COMMA, expr) { $1 }
113 | LEFT_PAREN separated_list(COMMA, expr) RIGHT_PAREN { $2 }