Theme Editor: Added column number to parser error messages
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27477 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
eb52a45a0c
commit
3c4fb8abe4
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -211,7 +211,9 @@ void SkinDocument::cursorChanged()
|
|||
skin_parse(line.selectedText().toAscii());
|
||||
if(skin_error_line() > 0)
|
||||
parseStatus = tr("Error on line ") +
|
||||
QString::number(line.blockNumber() + 1) + tr(": ") +
|
||||
QString::number(line.blockNumber() + 1)
|
||||
+ tr(", column ") + QString::number(skin_error_col())
|
||||
+ tr(": ") +
|
||||
skin_error_message();
|
||||
statusLabel->setText(parseStatus);
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ QString ParseTreeModel::changeTree(const char *document)
|
|||
{
|
||||
QString error = tr("Error on line ") +
|
||||
QString::number(skin_error_line())
|
||||
+ tr(", column ") + QString::number(skin_error_col())
|
||||
+ tr(": ") + QString(skin_error_message());
|
||||
return error;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user