diff options
Diffstat (limited to 'lib/skin_parser')
-rw-r--r-- | lib/skin_parser/skin_debug.c | 18 | ||||
-rw-r--r-- | lib/skin_parser/skin_debug.h | 3 | ||||
-rw-r--r-- | lib/skin_parser/skin_parser.c | 26 |
3 files changed, 33 insertions, 14 deletions
diff --git a/lib/skin_parser/skin_debug.c b/lib/skin_parser/skin_debug.c index 4abe6252f0..c03b32e910 100644 --- a/lib/skin_parser/skin_debug.c +++ b/lib/skin_parser/skin_debug.c @@ -30,15 +30,25 @@ /* Global variables for debug output */ int debug_indent_level = 0; extern int skin_line; +extern char* skin_start; /* Global error variables */ int error_line; +int error_col; char* error_message; /* Debugging functions */ -void skin_error(enum skin_errorcode error) +void skin_error(enum skin_errorcode error, char* cursor) { + error_col = 0; + + while(cursor > skin_start && *cursor != '\n') + { + cursor--; + error_col++; + } + error_line = skin_line; switch(error) @@ -91,6 +101,11 @@ int skin_error_line() return error_line; } +int skin_error_col() +{ + return error_col; +} + char* skin_error_message() { return error_message; @@ -99,6 +114,7 @@ char* skin_error_message() void skin_clear_errors() { error_line = 0; + error_col = 0; error_message = NULL; } diff --git a/lib/skin_parser/skin_debug.h b/lib/skin_parser/skin_debug.h index 8fc061a9f9..fbff5cbb4c 100644 --- a/lib/skin_parser/skin_debug.h +++ b/lib/skin_parser/skin_debug.h @@ -31,8 +31,9 @@ extern "C" #include "skin_parser.h" #ifndef ROCKBOX /* Debugging functions */ -void skin_error(enum skin_errorcode error); +void skin_error(enum skin_errorcode error, char* cursor); int skin_error_line(void); +int skin_error_col(void); char* skin_error_message(void); void skin_clear_errors(void); void skin_debug_tree(struct skin_element* root); diff --git a/lib/skin_parser/skin_parser.c b/lib/skin_parser/skin_parser.c index 5bc5984fb7..3e23067258 100644 --- a/lib/skin_parser/skin_parser.c +++ b/lib/skin_parser/skin_parser.c @@ -34,6 +34,7 @@ /* Global variables for the parser */ int skin_line = 0; +char* skin_start = 0; int viewport_line = 0; /* Auxiliary parsing functions (not visible at global scope) */ @@ -66,6 +67,7 @@ struct skin_element* skin_parse(const char* document) char* cursor = (char*)document; /*Keeps track of location in the document*/ skin_line = 1; + skin_start = (char*)document; viewport_line = 0; skin_clear_errors(); @@ -381,7 +383,7 @@ static struct skin_element* skin_parse_sublines_optional(char** document, if(*cursor != MULTILINESYM && i != sublines - 1) { - skin_error(MULTILINE_EXPECTED); + skin_error(MULTILINE_EXPECTED, cursor); return NULL; } else if(i != sublines - 1) @@ -433,7 +435,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) if(!tag) { - skin_error(ILLEGAL_TAG); + skin_error(ILLEGAL_TAG, cursor); return 0; } @@ -464,7 +466,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) /* Checking the number of arguments and allocating args */ if(*cursor != ARGLISTOPENSYM && tag_args[0] != '|') { - skin_error(ARGLIST_EXPECTED); + skin_error(ARGLIST_EXPECTED, cursor); return 0; } else @@ -512,7 +514,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) /* Making sure we haven't run out of arguments */ if(*tag_args == '\0') { - skin_error(TOO_MANY_ARGS); + skin_error(TOO_MANY_ARGS, cursor); return 0; } @@ -545,7 +547,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) } else { - skin_error(DEFAULT_NOT_ALLOWED); + skin_error(DEFAULT_NOT_ALLOWED, cursor); return 0; } } @@ -554,7 +556,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) /* Scanning an int argument */ if(!isdigit(*cursor) && *cursor != '-') { - skin_error(INT_EXPECTED); + skin_error(INT_EXPECTED, cursor); return 0; } @@ -610,12 +612,12 @@ static int skin_parse_tag(struct skin_element* element, char** document) if(*cursor != ARGLISTSEPERATESYM && i < num_args - 1) { - skin_error(SEPERATOR_EXPECTED); + skin_error(SEPERATOR_EXPECTED, cursor); return 0; } else if(*cursor != ARGLISTCLOSESYM && i == num_args - 1) { - skin_error(CLOSE_EXPECTED); + skin_error(CLOSE_EXPECTED, cursor); return 0; } else @@ -639,7 +641,7 @@ static int skin_parse_tag(struct skin_element* element, char** document) /* Checking for a premature end */ if(*tag_args != '\0' && !optional) { - skin_error(INSUFFICIENT_ARGS); + skin_error(INSUFFICIENT_ARGS, cursor); return 0; } @@ -724,7 +726,7 @@ static int skin_parse_conditional(struct skin_element* element, char** document) /* Counting the children */ if(*(cursor++) != ENUMLISTOPENSYM) { - skin_error(ARGLIST_EXPECTED); + skin_error(ARGLIST_EXPECTED, cursor); return 0; } bookmark = cursor; @@ -768,12 +770,12 @@ static int skin_parse_conditional(struct skin_element* element, char** document) if(i < children - 1 && *cursor != ENUMLISTSEPERATESYM) { - skin_error(SEPERATOR_EXPECTED); + skin_error(SEPERATOR_EXPECTED, cursor); return 0; } else if(i == children - 1 && *cursor != ENUMLISTCLOSESYM) { - skin_error(CLOSE_EXPECTED); + skin_error(CLOSE_EXPECTED, cursor); return 0; } else |