diff options
author | Thomas Martitz <kugel@rockbox.org> | 2012-04-17 17:06:51 +0200 |
---|---|---|
committer | Thomas Martitz <kugel@rockbox.org> | 2012-04-17 17:07:43 +0200 |
commit | 728db2150277206ae82d6f5ed82b86cf779ee653 (patch) | |
tree | 6869ff16071c31c5a5e0679b095edd8e8f2aade6 | |
parent | e43b856ed0f2fa3cb03a1335c9dc311b572e88e2 (diff) | |
download | rockbox-728db2150277206ae82d6f5ed82b86cf779ee653.tar.gz rockbox-728db2150277206ae82d6f5ed82b86cf779ee653.zip |
Revert "skin_engine: rework the parser to be closer to the langauge grammar."
This reverts commit ec8b21eef8b2fe1bd02f335dbc0dfbf05c2deff2 which was pushed by accident.
Change-Id: I1aaedf6876d0448a100dc582b79f1293d021bac1
Reviewed-on: http://gerrit.rockbox.org/216
Reviewed-by: Thomas Martitz <kugel@rockbox.org>
-rw-r--r-- | lib/skin_parser/skin_parser.c | 65 | ||||
-rw-r--r-- | lib/skin_parser/skin_scan.c | 71 | ||||
-rw-r--r-- | lib/skin_parser/skin_scan.h | 1 |
3 files changed, 80 insertions, 57 deletions
diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 44a1c03245..a81bcded34 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c | |||
@@ -182,12 +182,26 @@ static struct skin_element* skin_parse_viewport(const char** document) | |||
182 | } | 182 | } |
183 | else if(*cursor == TAGSYM) | 183 | else if(*cursor == TAGSYM) |
184 | { | 184 | { |
185 | skip_tag(&cursor); | 185 | /* A ';' directly after a '%' doesn't count */ |
186 | cursor ++; | ||
187 | |||
188 | if(*cursor == '\0') | ||
189 | break; | ||
190 | |||
191 | cursor++; | ||
186 | } | 192 | } |
187 | else if(*cursor == COMMENTSYM) | 193 | else if(*cursor == COMMENTSYM) |
188 | { | 194 | { |
189 | skip_comment(&cursor); | 195 | skip_comment(&cursor); |
190 | } | 196 | } |
197 | else if(*cursor == ARGLISTOPENSYM) | ||
198 | { | ||
199 | skip_arglist(&cursor); | ||
200 | } | ||
201 | else if(*cursor == ENUMLISTOPENSYM) | ||
202 | { | ||
203 | skip_enumlist(&cursor); | ||
204 | } | ||
191 | else | 205 | else |
192 | { | 206 | { |
193 | /* Advancing the cursor as normal */ | 207 | /* Advancing the cursor as normal */ |
@@ -431,9 +445,20 @@ static struct skin_element* skin_parse_sublines_optional(const char** document, | |||
431 | { | 445 | { |
432 | skip_comment(&cursor); | 446 | skip_comment(&cursor); |
433 | } | 447 | } |
448 | else if(*cursor == ENUMLISTOPENSYM) | ||
449 | { | ||
450 | skip_enumlist(&cursor); | ||
451 | } | ||
452 | else if(*cursor == ARGLISTOPENSYM) | ||
453 | { | ||
454 | skip_arglist(&cursor); | ||
455 | } | ||
434 | else if(*cursor == TAGSYM) | 456 | else if(*cursor == TAGSYM) |
435 | { | 457 | { |
436 | skip_tag(&cursor); | 458 | cursor++; |
459 | if(*cursor == '\0' || *cursor == '\n') | ||
460 | break; | ||
461 | cursor++; | ||
437 | } | 462 | } |
438 | else if(*cursor == MULTILINESYM) | 463 | else if(*cursor == MULTILINESYM) |
439 | { | 464 | { |
@@ -570,12 +595,19 @@ static int skin_parse_tag(struct skin_element* element, const char** document) | |||
570 | /* Skipping over escaped characters */ | 595 | /* Skipping over escaped characters */ |
571 | if(*cursor == TAGSYM) | 596 | if(*cursor == TAGSYM) |
572 | { | 597 | { |
573 | skip_tag(&cursor); | 598 | cursor++; |
599 | if(*cursor == '\0') | ||
600 | break; | ||
601 | cursor++; | ||
574 | } | 602 | } |
575 | else if(*cursor == COMMENTSYM) | 603 | else if(*cursor == COMMENTSYM) |
576 | { | 604 | { |
577 | skip_comment(&cursor); | 605 | skip_comment(&cursor); |
578 | } | 606 | } |
607 | else if(*cursor == ARGLISTOPENSYM) | ||
608 | { | ||
609 | skip_arglist(&cursor); | ||
610 | } | ||
579 | else if(*cursor == ARGLISTSEPARATESYM) | 611 | else if(*cursor == ARGLISTSEPARATESYM) |
580 | { | 612 | { |
581 | num_args++; | 613 | num_args++; |
@@ -942,9 +974,18 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc | |||
942 | { | 974 | { |
943 | skip_comment(&cursor); | 975 | skip_comment(&cursor); |
944 | } | 976 | } |
977 | else if(*cursor == ENUMLISTOPENSYM) | ||
978 | { | ||
979 | if (*cursor == '\n') | ||
980 | cursor++; | ||
981 | skip_enumlist(&cursor); | ||
982 | } | ||
945 | else if(*cursor == TAGSYM) | 983 | else if(*cursor == TAGSYM) |
946 | { | 984 | { |
947 | skip_tag(&cursor); | 985 | cursor++; |
986 | if(*cursor == '\0' || *cursor == '\n') | ||
987 | break; | ||
988 | cursor++; | ||
948 | } | 989 | } |
949 | else if(*cursor == ENUMLISTSEPARATESYM) | 990 | else if(*cursor == ENUMLISTSEPARATESYM) |
950 | { | 991 | { |
@@ -1098,7 +1139,21 @@ static struct skin_element* skin_parse_code_as_arg(const char** document) | |||
1098 | } | 1139 | } |
1099 | else if(*cursor == TAGSYM) | 1140 | else if(*cursor == TAGSYM) |
1100 | { | 1141 | { |
1101 | skip_tag(&cursor); | 1142 | /* A ';' directly after a '%' doesn't count */ |
1143 | cursor ++; | ||
1144 | |||
1145 | if(*cursor == '\0') | ||
1146 | break; | ||
1147 | |||
1148 | cursor++; | ||
1149 | } | ||
1150 | else if(*cursor == ARGLISTOPENSYM) | ||
1151 | { | ||
1152 | skip_arglist(&cursor); | ||
1153 | } | ||
1154 | else if(*cursor == ENUMLISTOPENSYM) | ||
1155 | { | ||
1156 | skip_enumlist(&cursor); | ||
1102 | } | 1157 | } |
1103 | else | 1158 | else |
1104 | { | 1159 | { |
diff --git a/lib/skin_parser/skin_scan.c b/lib/skin_parser/skin_scan.c index f6424aba53..50d58bc250 100644 --- a/lib/skin_parser/skin_scan.c +++ b/lib/skin_parser/skin_scan.c | |||
@@ -28,7 +28,6 @@ | |||
28 | #include "skin_debug.h" | 28 | #include "skin_debug.h" |
29 | #include "symbols.h" | 29 | #include "symbols.h" |
30 | #include "skin_parser.h" | 30 | #include "skin_parser.h" |
31 | #include "tag_table.h" | ||
32 | 31 | ||
33 | /* Scanning Functions */ | 32 | /* Scanning Functions */ |
34 | 33 | ||
@@ -41,54 +40,6 @@ void skip_comment(const char** document) | |||
41 | (*document)++; | 40 | (*document)++; |
42 | } | 41 | } |
43 | 42 | ||
44 | void skip_tag(const char** document) | ||
45 | { | ||
46 | char tag_name[MAX_TAG_LENGTH]; | ||
47 | int i; | ||
48 | bool qmark; | ||
49 | const struct tag_info *tag; | ||
50 | const char *cursor; | ||
51 | |||
52 | if(**document == TAGSYM) | ||
53 | (*document)++; | ||
54 | qmark = (**document == CONDITIONSYM); | ||
55 | if (qmark) | ||
56 | (*document)++; | ||
57 | |||
58 | if (!qmark && find_escape_character(**document)) | ||
59 | { | ||
60 | (*document)++; | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | cursor = *document; | ||
65 | |||
66 | /* Checking the tag name */ | ||
67 | for (i=0; cursor[i] && i<MAX_TAG_LENGTH; i++) | ||
68 | tag_name[i] = cursor[i]; | ||
69 | |||
70 | /* First we check the two characters after the '%', then a single char */ | ||
71 | tag = NULL; | ||
72 | i = MAX_TAG_LENGTH; | ||
73 | while (!tag && i > 1) | ||
74 | { | ||
75 | tag_name[i-1] = '\0'; | ||
76 | tag = find_tag(tag_name); | ||
77 | i--; | ||
78 | } | ||
79 | |||
80 | if (tag) | ||
81 | { | ||
82 | *document += strlen(tag->name); | ||
83 | } | ||
84 | } | ||
85 | if (**document == ARGLISTOPENSYM) | ||
86 | skip_arglist(document); | ||
87 | |||
88 | if (**document == ENUMLISTOPENSYM) | ||
89 | skip_enumlist(document); | ||
90 | } | ||
91 | |||
92 | void skip_arglist(const char** document) | 43 | void skip_arglist(const char** document) |
93 | { | 44 | { |
94 | if(**document == ARGLISTOPENSYM) | 45 | if(**document == ARGLISTOPENSYM) |
@@ -96,7 +47,16 @@ void skip_arglist(const char** document) | |||
96 | while(**document && **document != ARGLISTCLOSESYM) | 47 | while(**document && **document != ARGLISTCLOSESYM) |
97 | { | 48 | { |
98 | if(**document == TAGSYM) | 49 | if(**document == TAGSYM) |
99 | skip_tag(document); | 50 | { |
51 | (*document)++; | ||
52 | if(**document == '\0') | ||
53 | break; | ||
54 | (*document)++; | ||
55 | } | ||
56 | else if(**document == ARGLISTOPENSYM) | ||
57 | skip_arglist(document); | ||
58 | else if(**document == ENUMLISTOPENSYM) | ||
59 | skip_enumlist(document); | ||
100 | else if(**document == COMMENTSYM) | 60 | else if(**document == COMMENTSYM) |
101 | skip_comment(document); | 61 | skip_comment(document); |
102 | else | 62 | else |
@@ -113,7 +73,16 @@ void skip_enumlist(const char** document) | |||
113 | while(**document && **document != ENUMLISTCLOSESYM) | 73 | while(**document && **document != ENUMLISTCLOSESYM) |
114 | { | 74 | { |
115 | if(**document == TAGSYM) | 75 | if(**document == TAGSYM) |
116 | skip_tag(document); | 76 | { |
77 | (*document)++; | ||
78 | if(**document == '\0') | ||
79 | break; | ||
80 | (*document)++; | ||
81 | } | ||
82 | else if(**document == ARGLISTOPENSYM) | ||
83 | skip_arglist(document); | ||
84 | else if(**document == ENUMLISTOPENSYM) | ||
85 | skip_enumlist(document); | ||
117 | else if(**document == COMMENTSYM) | 86 | else if(**document == COMMENTSYM) |
118 | skip_comment(document); | 87 | skip_comment(document); |
119 | else | 88 | else |
diff --git a/lib/skin_parser/skin_scan.h b/lib/skin_parser/skin_scan.h index 6281582b88..47d8289f98 100644 --- a/lib/skin_parser/skin_scan.h +++ b/lib/skin_parser/skin_scan.h | |||
@@ -29,7 +29,6 @@ extern "C" | |||
29 | 29 | ||
30 | 30 | ||
31 | /* Scanning functions */ | 31 | /* Scanning functions */ |
32 | void skip_tag(const char** document); | ||
33 | void skip_comment(const char** document); | 32 | void skip_comment(const char** document); |
34 | void skip_arglist(const char** document); | 33 | void skip_arglist(const char** document); |
35 | void skip_enumlist(const char** document); | 34 | void skip_enumlist(const char** document); |