diff --git a/moo/mooutils/mooscript/mooscript-parser.c b/moo/mooutils/mooscript/mooscript-parser.c index 368cc3a5..57f90600 100644 --- a/moo/mooutils/mooscript/mooscript-parser.c +++ b/moo/mooutils/mooscript/mooscript-parser.c @@ -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; } diff --git a/moo/mooutils/mooscript/mooscript-yacc.c b/moo/mooutils/mooscript/mooscript-yacc.c index bb3a7ad1..8ad7df0a 100644 --- a/moo/mooutils/mooscript/mooscript-yacc.c +++ b/moo/mooutils/mooscript/mooscript-yacc.c @@ -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; diff --git a/moo/mooutils/mooscript/mooscript-yacc.h b/moo/mooutils/mooscript/mooscript-yacc.h index 5c0b2452..0b66012f 100644 --- a/moo/mooutils/mooscript/mooscript-yacc.h +++ b/moo/mooutils/mooscript/mooscript-yacc.h @@ -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; diff --git a/moo/mooutils/mooscript/mooscript-yacc.y b/moo/mooutils/mooscript/mooscript-yacc.y index 17c78647..ebd05ffd 100644 --- a/moo/mooutils/mooscript/mooscript-yacc.y +++ b/moo/mooutils/mooscript/mooscript-yacc.y @@ -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 '%' diff --git a/tests/mscript.c b/tests/mscript.c index a351a93e..95b911e2 100644 --- a/tests/mscript.c +++ b/tests/mscript.c @@ -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 ();