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
39 (* Start nonterminals. *)
41 %start <Ast.expr> expr
51 fun env (name, expr) -> Ast.StringMap.add name expr env
52 ) Ast.StringMap.empty $1
56 | option(goal_stmt) patterns COLON barelist option(CODE)
60 let pos = $startpos in
61 sprintf "_goal@%d" pos.pos_lnum, []
63 name, Ast.EGoal (params, $2, $4, $5)
67 let name, params = $1 in
68 name, Ast.EGoal (params, [], [], Some $2)
70 | LET ID EQUALS expr { $2, $4 }
74 | GOAL ID option(param_decl) EQUALS
75 { $2, match $3 with None -> [] | Some ps -> ps }
78 | LEFT_PAREN separated_list(COMMA, ID) RIGHT_PAREN { $2 }
82 | separated_list(COMMA, pattern) { $1 }
85 | STRING { Ast.PTactic ("file", [$1]) }
86 | ID pattern_params { Ast.PTactic ($1, $2) }
90 | LEFT_PAREN separated_list(COMMA, pattern_param) RIGHT_PAREN { $2 }
97 | ID params { Ast.ECall ($1, $2) }
98 | ID { Ast.EVar $1 (* This might be replaced with ECall later. *) }
99 | STRING { Ast.ESubsts $1 }
100 | LEFT_ARRAY barelist RIGHT_ARRAY { Ast.EList $2 }
103 | separated_list(COMMA, expr) { $1 }
106 | LEFT_PAREN separated_list(COMMA, expr) RIGHT_PAREN { $2 }