1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 Robert Bieber
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #ifndef GENERIC_PARSER_H
23 #define GENERIC_PARSER_H
31 #define SKIN_MAX_MEMORY 1048576
33 /********************************************************************
34 ****** A global buffer will be used to store the parse tree *******
35 *******************************************************************/
36 extern char skin_parse_tree
[];
38 /********************************************************************
39 ****** Data Structures *********************************************
40 *******************************************************************/
42 /* Possible types of element in a WPS file */
43 enum skin_element_type
57 MEMORY_LIMIT_EXCEEDED
,
71 /* Holds a tag parameter, either numeric or text */
72 struct skin_tag_parameter
86 struct skin_element
* code
;
93 /* Defines an element of a SKIN file */
96 /* Defines what type of element it is */
97 enum skin_element_type type
;
99 /* The line on which it's defined in the source file */
102 /* Text for comments and plaintext */
105 /* The tag or conditional name */
106 struct tag_info
*tag
;
108 /* Pointer to and size of an array of parameters */
110 struct skin_tag_parameter
* params
;
112 /* Pointer to and size of an array of children */
114 struct skin_element
** children
;
116 /* Link to the next element */
117 struct skin_element
* next
;
120 /***********************************************************************
121 ***** Functions *******************************************************
122 **********************************************************************/
124 /* Parses a WPS document and returns a list of skin_element
126 struct skin_element
* skin_parse(const char* document
);
128 /* Memory management functions */
129 struct skin_element
* skin_alloc_element();
130 struct skin_element
** skin_alloc_children(int count
);
131 struct skin_tag_parameter
* skin_alloc_params(int count
);
132 char* skin_alloc_string(int length
);
134 void skin_free_tree(struct skin_element
* root
);
140 #endif /* GENERIC_PARSER_H */