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
42 (* Start non-terminal. *)
43 %start <Ast.file> file
54 | option(goal_stmt) patterns COLON barelist option(CODE)
58 let pos = $startpos in
59 sprintf "_goal@%d" pos.pos_lnum, []
61 Ast.Goal (name, params, $2, $4, $5)
65 let name, params = $1 in
66 Ast.Goal (name, params, [], [], Some $2)
68 | LET ID EQUALS expr { Ast.Let ($2, $4) }
72 | GOAL ID option(param_decl) EQUALS
73 { $2, match $3 with None -> [] | Some ps -> ps }
76 | LEFT_PAREN separated_list(COMMA, ID) RIGHT_PAREN { $2 }
80 | separated_list(COMMA, pattern) { $1 }
83 | STRING { Ast.PTactic ("file", [$1]) }
84 | ID pattern_params { Ast.PTactic ($1, $2) }
85 | ID { Ast.PVarSubst $1 }
88 | LEFT_PAREN separated_list(COMMA, pattern_param) RIGHT_PAREN { $2 }
95 | ID params { Ast.ECall ($1, $2) }
96 | ID { Ast.EVar $1 (* This might be replaced with ECall later. *) }
97 | STRING { Ast.EString $1 }
98 | LEFT_ARRAY barelist RIGHT_ARRAY { Ast.EList $2 }
101 | separated_list(COMMA, expr) { $1 }
104 | LEFT_PAREN separated_list(COMMA, expr) RIGHT_PAREN { $2 }