diff options
author | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-11 04:47:46 +0000 |
---|---|---|
committer | Jonathan Gordon <rockbox@jdgordon.info> | 2010-06-11 04:47:46 +0000 |
commit | b4a9564790575c645d855c23f7f2e07ae03c1c19 (patch) | |
tree | 39aa7fa77345edb78f4b4e9a9745aaf88c69f689 /utils/newparser/newparser.c | |
parent | 45c7498f59ad2889f2120a865a51043004eddd5d (diff) | |
download | rockbox-b4a9564790575c645d855c23f7f2e07ae03c1c19.tar.gz rockbox-b4a9564790575c645d855c23f7f2e07ae03c1c19.zip |
Add my new parser playground to svn.
Currently it can load a skin, and walk the parse tree and output the tags as required. It always chooses the first value for a conditional and subline, but a good working start
there seems to be a error in the new parser if ROCKBOX is defined... need to fix that
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26757 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/newparser/newparser.c')
-rw-r--r-- | utils/newparser/newparser.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/utils/newparser/newparser.c b/utils/newparser/newparser.c new file mode 100644 index 0000000000..2f58b64d15 --- /dev/null +++ b/utils/newparser/newparser.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: tag_table.c 26346 2010-05-28 02:30:27Z jdgordon $ | ||
9 | * | ||
10 | * Copyright (C) 2010 Jonathan Gordon | ||
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 | #include <stdio.h> | ||
23 | #include <stdlib.h> | ||
24 | #include <stdbool.h> | ||
25 | #include <string.h> | ||
26 | #include <ctype.h> | ||
27 | |||
28 | #include "skin_parser.h" | ||
29 | #include "tag_table.h" | ||
30 | #include "skin_structs.h" | ||
31 | |||
32 | int handle_tree(struct skin *skin, struct skin_element* tree); | ||
33 | void skin_render(struct skin_element* root); | ||
34 | |||
35 | int main(int argc, char* argv[]) | ||
36 | { | ||
37 | char buffer[10*1024], temp[512]; | ||
38 | FILE *in; | ||
39 | int filearg = 1, i=0; | ||
40 | if( (argc < 2) || | ||
41 | strcmp(argv[1],"-h") == 0 || | ||
42 | strcmp(argv[1],"--help") == 0 ) | ||
43 | { | ||
44 | printf("Usage: %s infile \n", argv[0]); | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | while ((argc > filearg) && argv[filearg][0] == '-') | ||
49 | { | ||
50 | i=1; | ||
51 | while (argv[filearg][i]) | ||
52 | { | ||
53 | switch(argv[filearg][i]) | ||
54 | { | ||
55 | } | ||
56 | i++; | ||
57 | } | ||
58 | filearg++; | ||
59 | } | ||
60 | if (argc == filearg) | ||
61 | { | ||
62 | printf("Missing input filename\n"); | ||
63 | return 1; | ||
64 | } | ||
65 | |||
66 | in = fopen(argv[filearg], "r"); | ||
67 | if (!in) | ||
68 | return 1; | ||
69 | while (fgets(temp, 512, in)) | ||
70 | strcat(buffer, temp); | ||
71 | fclose(in); | ||
72 | filearg++; | ||
73 | |||
74 | struct skin_element* tree = skin_parse(buffer); | ||
75 | struct skin skin; | ||
76 | skin_render(tree); | ||
77 | //handle_tree(&skin, tree); | ||
78 | |||
79 | skin_free_tree(tree); | ||
80 | return 0; | ||
81 | } | ||