4 * Copyright (C) 2015 Alexander Andrejevic <theflash AT sdf DOT lonestar DOT org>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>
37 %token LEFT_PARENTHESIS
38 %token RIGHT_PARENTHESIS
42 %token <number> NUMBER
43 %token <string> STRING
45 %type <list> element_list statement_list
46 %type <element> element tuple statement
52 toplevel : statement_list
57 statement_list : /* empty */
61 | statement_list comment
63 /* Skip the comment */
66 | statement_list statement
68 list_append(&$1, &$2->link);
72 statement : LEFT_CHEVRON ATOM element_list RIGHT_CHEVRON
74 $$ = create_statement($2, &$3);
77 tuple : LEFT_PARENTHESIS element_list RIGHT_PARENTHESIS
79 $$ = create_tuple(&$2);
82 element_list : /* empty */
86 | element_list comment
88 /* Skip the comment */
91 | element_list element
93 list_append(&$1, &$2->link);
99 $$ = create_atom($1, 0);
103 $$ = create_atom($2, 1);
107 $$ = create_string($1);
111 $$ = create_number($1);
122 comment : SEMICOLON element { /* Ignored */ }
126 int yyerror(const char *str)