1 /* $Id$ */ 2 /* Copyright (c) 2008-2014 Pierre Pronchery <khorben@defora.org> */ 3 /* This file is part of DeforaOS System libSystem */ 4 /* This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License as published by 6 * the Free Software Foundation, version 3 of the License. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 15 16 17 18 #ifndef LIBSYSTEM_SYSTEM_PARSER_H 19 # define LIBSYSTEM_SYSTEM_PARSER_H 20 21 # include "token.h" 22 23 24 /* Parser */ 25 /* types */ 26 typedef struct _Parser Parser; 27 typedef int (*ParserFilter)(int * c, void * data); 28 typedef int (*ParserCallback)(Parser * parser, Token * token, int c, 29 void * data); 30 31 32 /* functions */ 33 Parser * parser_new(char const * pathname); 34 Parser * parser_new_string(char const * string, size_t length); 35 int parser_delete(Parser * parser); 36 37 /* accessors */ 38 char const * parser_get_filename(Parser * parser); 39 int parser_get_token(Parser * parser, Token ** token); 40 41 /* useful */ 42 int parser_add_callback(Parser * parser, ParserCallback callback, 43 void * data); 44 int parser_remove_callback(Parser * parser, ParserCallback callback); 45 46 int parser_add_filter(Parser * parser, ParserFilter filter, void * data); 47 int parser_remove_filter(Parser * parser, ParserFilter filter); 48 49 int parser_scan(Parser * parser); 50 int parser_scan_filter(Parser * parser); 51 52 #endif /* !LIBSYSTEM_SYSTEM_PARSER_H */ 53