]>
Commit | Line | Data |
---|---|---|
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 | ||
27 | typedef struct yy_buffer_state* YY_BUFFER_STATE; | |
28 | extern YY_BUFFER_STATE yy_scan_bytes(const char* buffer, size_t len); | |
29 | extern void yy_delete_buffer(YY_BUFFER_STATE buffer); | |
30 | ||
31 | extern int yylex(); | |
32 | extern int yyparse(); | |
33 | void 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 | ||
48 | top: NEWLINE | |
49 | ||
50 | %% | |
51 | ||
52 | int 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 | ||
60 | void yyerror(const char* s) { | |
61 | fprintf(stderr, "Parse error: %s\n", s); | |
62 | abort(); | |
63 | } |