summaryrefslogtreecommitdiffstats
path: root/lib/skin_parser
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2012-04-17 17:06:51 +0200
committerThomas Martitz <kugel@rockbox.org>2012-04-17 17:07:43 +0200
commit728db2150277206ae82d6f5ed82b86cf779ee653 (patch)
tree6869ff16071c31c5a5e0679b095edd8e8f2aade6 /lib/skin_parser
parente43b856ed0f2fa3cb03a1335c9dc311b572e88e2 (diff)
downloadrockbox-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>
Diffstat (limited to 'lib/skin_parser')
-rw-r--r--lib/skin_parser/skin_parser.c65
-rw-r--r--lib/skin_parser/skin_scan.c71
-rw-r--r--lib/skin_parser/skin_scan.h1
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)
}
else if(*cursor == TAGSYM)
{
- skip_tag(&cursor);
+ /* A ';' directly after a '%' doesn't count */
+ cursor ++;
+
+ if(*cursor == '\0')
+ break;
+
+ cursor++;
}
else if(*cursor == COMMENTSYM)
{
skip_comment(&cursor);
}
+ else if(*cursor == ARGLISTOPENSYM)
+ {
+ skip_arglist(&cursor);
+ }
+ else if(*cursor == ENUMLISTOPENSYM)
+ {
+ skip_enumlist(&cursor);
+ }
else
{
/* Advancing the cursor as normal */
@@ -431,9 +445,20 @@ static struct skin_element* skin_parse_sublines_optional(const char** document,
{
skip_comment(&cursor);
}
+ else if(*cursor == ENUMLISTOPENSYM)
+ {
+ skip_enumlist(&cursor);
+ }
+ else if(*cursor == ARGLISTOPENSYM)
+ {
+ skip_arglist(&cursor);
+ }
else if(*cursor == TAGSYM)
{
- skip_tag(&cursor);
+ cursor++;
+ if(*cursor == '\0' || *cursor == '\n')
+ break;
+ cursor++;
}
else if(*cursor == MULTILINESYM)
{
@@ -570,12 +595,19 @@ static int skin_parse_tag(struct skin_element* element, const char** document)
/* Skipping over escaped characters */
if(*cursor == TAGSYM)
{
- skip_tag(&cursor);
+ cursor++;
+ if(*cursor == '\0')
+ break;
+ cursor++;
}
else if(*cursor == COMMENTSYM)
{
skip_comment(&cursor);
}
+ else if(*cursor == ARGLISTOPENSYM)
+ {
+ skip_arglist(&cursor);
+ }
else if(*cursor == ARGLISTSEPARATESYM)
{
num_args++;
@@ -942,9 +974,18 @@ static int skin_parse_conditional(struct skin_element* element, const char** doc
{
skip_comment(&cursor);
}
+ else if(*cursor == ENUMLISTOPENSYM)
+ {
+ if (*cursor == '\n')
+ cursor++;
+ skip_enumlist(&cursor);
+ }
else if(*cursor == TAGSYM)
{
- skip_tag(&cursor);
+ cursor++;
+ if(*cursor == '\0' || *cursor == '\n')
+ break;
+ cursor++;
}
else if(*cursor == ENUMLISTSEPARATESYM)
{
@@ -1098,7 +1139,21 @@ static struct skin_element* skin_parse_code_as_arg(const char** document)
}
else if(*cursor == TAGSYM)
{
- skip_tag(&cursor);
+ /* A ';' directly after a '%' doesn't count */
+ cursor ++;
+
+ if(*cursor == '\0')
+ break;
+
+ cursor++;
+ }
+ else if(*cursor == ARGLISTOPENSYM)
+ {
+ skip_arglist(&cursor);
+ }
+ else if(*cursor == ENUMLISTOPENSYM)
+ {
+ skip_enumlist(&cursor);
}
else
{
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 @@
#include "skin_debug.h"
#include "symbols.h"
#include "skin_parser.h"
-#include "tag_table.h"
/* Scanning Functions */
@@ -41,54 +40,6 @@ void skip_comment(const char** document)
(*document)++;
}
-void skip_tag(const char** document)
-{
- char tag_name[MAX_TAG_LENGTH];
- int i;
- bool qmark;
- const struct tag_info *tag;
- const char *cursor;
-
- if(**document == TAGSYM)
- (*document)++;
- qmark = (**document == CONDITIONSYM);
- if (qmark)
- (*document)++;
-
- if (!qmark && find_escape_character(**document))
- {
- (*document)++;
- }
- else
- {
- cursor = *document;
-
- /* Checking the tag name */
- for (i=0; cursor[i] && i<MAX_TAG_LENGTH; i++)
- tag_name[i] = cursor[i];
-
- /* First we check the two characters after the '%', then a single char */
- tag = NULL;
- i = MAX_TAG_LENGTH;
- while (!tag && i > 1)
- {
- tag_name[i-1] = '\0';
- tag = find_tag(tag_name);
- i--;
- }
-
- if (tag)
- {
- *document += strlen(tag->name);
- }
- }
- if (**document == ARGLISTOPENSYM)
- skip_arglist(document);
-
- if (**document == ENUMLISTOPENSYM)
- skip_enumlist(document);
-}
-
void skip_arglist(const char** document)
{
if(**document == ARGLISTOPENSYM)
@@ -96,7 +47,16 @@ void skip_arglist(const char** document)
while(**document && **document != ARGLISTCLOSESYM)
{
if(**document == TAGSYM)
- skip_tag(document);
+ {
+ (*document)++;
+ if(**document == '\0')
+ break;
+ (*document)++;
+ }
+ else if(**document == ARGLISTOPENSYM)
+ skip_arglist(document);
+ else if(**document == ENUMLISTOPENSYM)
+ skip_enumlist(document);
else if(**document == COMMENTSYM)
skip_comment(document);
else
@@ -113,7 +73,16 @@ void skip_enumlist(const char** document)
while(**document && **document != ENUMLISTCLOSESYM)
{
if(**document == TAGSYM)
- skip_tag(document);
+ {
+ (*document)++;
+ if(**document == '\0')
+ break;
+ (*document)++;
+ }
+ else if(**document == ARGLISTOPENSYM)
+ skip_arglist(document);
+ else if(**document == ENUMLISTOPENSYM)
+ skip_enumlist(document);
else if(**document == COMMENTSYM)
skip_comment(document);
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"
/* Scanning functions */
-void skip_tag(const char** document);
void skip_comment(const char** document);
void skip_arglist(const char** document);
void skip_enumlist(const char** document);