Use verbose error messages

master
Yevgen Muntyan 2006-03-08 03:02:04 -06:00
parent 94e9641264
commit 13e72f4c98
5 changed files with 27 additions and 15 deletions

View File

@ -194,7 +194,7 @@ ms_lex_parse_number (MSLex *lex,
{
if (value > 1000000)
{
g_warning ("number is too big");
g_print ("syntax error, number is too big\n", G_STRLOC);
return ms_lex_error (parser);
}
@ -203,7 +203,7 @@ ms_lex_parse_number (MSLex *lex,
}
else if (IS_WORD (c))
{
g_warning ("number followed by word char");
g_print ("syntax error, number followed by word char\n", G_STRLOC);
return ms_lex_error (parser);
}
else
@ -213,8 +213,8 @@ ms_lex_parse_number (MSLex *lex,
}
}
g_critical ("oops");
return ms_lex_error (parser);
_ms_script_yylval.ival = value;
return NUMBER;
}
@ -379,7 +379,7 @@ void
_ms_script_yyerror (MSParser *parser,
const char *string)
{
g_print ("error: %s\n", string);
g_print ("%s\n", string);
parser->failed = TRUE;
}

View File

@ -492,7 +492,7 @@ node_dict_assign (MSParser *parser,
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
# define YYERROR_VERBOSE 1
#endif
/* Enabling the token table. */
@ -501,7 +501,7 @@ node_dict_assign (MSParser *parser,
#endif
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 360 "/home/muntyan/projects/moo/moo/mooutils/mooscript/mooscript-yacc.y"
#line 364 "/home/muntyan/projects/moo/moo/mooutils/mooscript/mooscript-yacc.y"
typedef union YYSTYPE {
int ival;
const char *str;

View File

@ -89,7 +89,7 @@
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
#line 360 "/home/muntyan/projects/moo/moo/mooutils/mooscript/mooscript-yacc.y"
#line 364 "/home/muntyan/projects/moo/moo/mooutils/mooscript/mooscript-yacc.y"
typedef union YYSTYPE {
int ival;
const char *str;

View File

@ -356,6 +356,10 @@ node_dict_assign (MSParser *parser,
%}
%name-prefix="_ms_script_yy"
%error-verbose
%lex-param {MSParser *parser}
%parse-param {MSParser *parser}
/* %expect 1 */
%union {
int ival;
@ -382,10 +386,6 @@ node_dict_assign (MSParser *parser,
%token UMINUS
%token TWODOTS
%lex-param {MSParser *parser}
%parse-param {MSParser *parser}
/* %expect 1 */
%left '-' '+'
%left '*' '/'
%left '%'

View File

@ -54,10 +54,7 @@ static int run_interactive (void)
free (line);
if (!node)
{
g_print ("syntax error\n");
continue;
}
val = ms_top_node_eval (node, ctx);
ms_node_unref (node);
@ -92,6 +89,21 @@ int main (int argc, char *argv[])
g_type_init ();
ms_type_init ();
if (argc > 1 && !strcmp (argv[1], "--g-fatal-warnings"))
{
GLogLevelFlags fatal_mask;
int i;
fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
g_log_set_always_fatal (fatal_mask);
for (i = 1; i < argc - 1; ++i)
argv[i] = argv[i+1];
argv[argc-1] = NULL;
argc -= 1;
}
if (argc < 2)
return run_interactive ();