]> git.ipfire.org Git - pakfire.git/blame - src/libpakfire/parser/grammar.y
libpakfire: Remove extra whitespace
[pakfire.git] / src / libpakfire / parser / grammar.y
CommitLineData
f9a691ef
MT
1/*#############################################################################
2# #
3# Pakfire - The IPFire package management system #
4# Copyright (C) 2019 Pakfire development team #
5# #
6# This program is free software: you can redistribute it and/or modify #
7# it under the terms of the GNU General Public License as published by #
8# the Free Software Foundation, either version 3 of the License, or #
9# (at your option) any later version. #
10# #
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 General Public License for more details. #
15# #
16# You should have received a copy of the GNU General Public License #
17# along with this program. If not, see <http://www.gnu.org/licenses/>. #
18# #
19#############################################################################*/
20
21%{
22#include <stdio.h>
23#include <stdlib.h>
24
25#define YYERROR_VERBOSE 1
26
27typedef struct yy_buffer_state* YY_BUFFER_STATE;
28extern YY_BUFFER_STATE yy_scan_bytes(const char* buffer, size_t len);
29extern void yy_delete_buffer(YY_BUFFER_STATE buffer);
30
31extern int yylex();
32extern int yyparse();
33void yyerror(const char* s);
34%}
35
36%token APPEND
37%token ASSIGN
38%token DEFINE
39%token END
40%token NEWLINE
41%token TAB
42%token VARIABLE
43%token VALUE
44%token WHITESPACE
45
46%%
47
48top: NEWLINE
49
50%%
51
52int pakfire_parser_parse_metadata(const char* data, size_t len) {
53 YY_BUFFER_STATE buffer = yy_scan_bytes(data, len);
54 int r = yyparse();
55 yy_delete_buffer(buffer);
56
57 return r;
58}
59
60void yyerror(const char* s) {
61 fprintf(stderr, "Parse error: %s\n", s);
62 abort();
63}