summaryrefslogtreecommitdiff
path: root/utils/themeeditor/skin_parser.h
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-05-25 15:19:52 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-05-25 15:19:52 +0000
commitd5b24ddcc57857d9db5751c2f6e51f55633459e7 (patch)
tree1ee27a146004aed6788d38f688718783822cf1c1 /utils/themeeditor/skin_parser.h
parentfd9d7d0ac103dc27ac4c79bcd715c2985b0bc559 (diff)
downloadrockbox-d5b24ddcc57857d9db5751c2f6e51f55633459e7.tar.gz
rockbox-d5b24ddcc57857d9db5751c2f6e51f55633459e7.zip
Adding the new WPS parser, code works but need to build the tag table
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26281 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/skin_parser.h')
-rw-r--r--utils/themeeditor/skin_parser.h124
1 files changed, 124 insertions, 0 deletions
diff --git a/utils/themeeditor/skin_parser.h b/utils/themeeditor/skin_parser.h
new file mode 100644
index 0000000000..a6fd1aa206
--- /dev/null
+++ b/utils/themeeditor/skin_parser.h
@@ -0,0 +1,124 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef GENERIC_PARSER_H
23#define GENERIC_PARSER_H
24
25#define SKIN_MAX_MEMORY 1048576
26
27/********************************************************************
28 ****** A global buffer will be used to store the parse tree *******
29 *******************************************************************/
30extern char skin_parse_tree[];
31
32/********************************************************************
33 ****** Data Structures *********************************************
34 *******************************************************************/
35
36/* Possible types of element in a WPS file */
37enum skin_element_type
38{
39 TEXT,
40 NEWLINE,
41 COMMENT,
42 TAG,
43 CONDITIONAL,
44 SUBLINES
45};
46
47enum skin_errorcode
48{
49 MEMORY_LIMIT_EXCEEDED,
50 NEWLINE_EXPECTED,
51 ILLEGAL_TAG,
52 ARGLIST_EXPECTED,
53 TOO_MANY_ARGS,
54 DEFAULT_NOT_ALLOWED,
55 UNEXPECTED_NEWLINE,
56 INSUFFICIENT_ARGS,
57 INT_EXPECTED,
58 SEPERATOR_EXPECTED,
59 CLOSE_EXPECTED,
60 MULTILINE_EXPECTED
61};
62
63/* Holds a tag parameter, either numeric or text */
64struct skin_tag_parameter
65{
66 enum
67 {
68 NUMERIC,
69 STRING,
70 CODE,
71 DEFAULT
72 } type;
73
74 union
75 {
76 int numeric;
77 char* text;
78 struct skin_element* code;
79 } data;
80
81};
82
83/* Defines an element of a SKIN file */
84struct skin_element
85{
86 /* Defines what type of element it is */
87 enum skin_element_type type;
88
89 /* The line on which it's defined in the source file */
90 int line;
91
92 /* Text for comments and plaintext */
93 char* text;
94
95 /* The tag or conditional name */
96 char* name;
97
98 /* Pointer to and size of an array of parameters */
99 int params_count;
100 struct skin_tag_parameter* params;
101
102 /* Pointer to and size of an array of children */
103 int children_count;
104 struct skin_element** children;
105
106 /* Link to the next element */
107 struct skin_element* next;
108};
109
110/***********************************************************************
111 ***** Functions *******************************************************
112 **********************************************************************/
113
114/* Parses a WPS document and returns a list of skin_element
115 structures. */
116struct skin_element* skin_parse(char* document);
117
118/* Memory management functions */
119struct skin_element* skin_alloc_element();
120struct skin_element** skin_alloc_children(int count);
121struct skin_tag_parameter* skin_alloc_params(int count);
122char* skin_alloc_string(int length);
123
124#endif /* GENERIC_PARSER_H */