Show line numbers in CTF parser errors
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 30 Mar 2013 14:07:11 +0000 (10:07 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 30 Mar 2013 14:07:11 +0000 (10:07 -0400)
Suggested-by: Etienne Bergeron <etienne.bergeron@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
formats/ctf/metadata/ctf-lexer.l
formats/ctf/metadata/ctf-parser.y
formats/ctf/metadata/ctf-scanner.h

index a779397479013a3ae4b86507a36a8b731db631b6..905da9916711831c1680479444f5b2898f88d846 100644 (file)
@@ -64,11 +64,11 @@ ESCSEQ                              \\(\'|\"|\?|\\|a|b|f|n|r|t|v|{OCTALDIGIT}{1,3}|u{HEXDIGIT}{4}|U{HEXDIG
 "/*"                           BEGIN(comment_ml);
 <comment_ml>[^*\n]*            /* eat anything that's not a '*' */
 <comment_ml>"*"+[^*/\n]*       /* eat up '*'s not followed by '/'s */
-<comment_ml>\n                 ++yylineno;
+<comment_ml>\n
 <comment_ml>"*"+"/"            BEGIN(INITIAL);
 
 "//"                           BEGIN(comment_sl);
-<comment_sl>[^\n]*\n           ++yylineno; BEGIN(INITIAL);
+<comment_sl>[^\n]*\n           BEGIN(INITIAL);
 
 L\'                            BEGIN(char_const); return CHARACTER_CONSTANT_START;
 \'                             BEGIN(char_const); return CHARACTER_CONSTANT_START;
index 72b0978e56f814c700e79bd36bb19c18b93c3f56..912f12123c7fa02f7e19c6378b7a341238914c1f 100644 (file)
@@ -65,6 +65,8 @@ BT_HIDDEN
 int yylex_destroy(yyscan_t yyscanner);
 BT_HIDDEN
 void yyrestart(FILE * in_str, yyscan_t scanner);
+BT_HIDDEN
+int yyget_lineno(yyscan_t yyscanner);
 
 struct gc_string {
        struct bt_list_head gc;
@@ -818,7 +820,8 @@ static int set_parent_node(struct ctf_node *node,
 BT_HIDDEN
 void yyerror(struct ctf_scanner *scanner, const char *str)
 {
-       fprintf(stderr, "error %s\n", str);
+       fprintf(stderr, "error at line %d: %s\n",
+               yyget_lineno(scanner->scanner), str);
 }
  
 BT_HIDDEN
@@ -936,6 +939,7 @@ void ctf_scanner_free(struct ctf_scanner *scanner)
 
 %define api.pure
        /* %locations */
+%error-verbose
 %parse-param {struct ctf_scanner *scanner}
 %lex-param {struct ctf_scanner *scanner}
 /*
index 21010fd4ef5a467be6453ef65459974fa3a73e07..262092f78cfea292ccb8991bc67daabe69fdd5a8 100644 (file)
@@ -37,6 +37,7 @@ struct ctf_scanner {
        struct ctf_scanner_scope root_scope;
        struct ctf_scanner_scope *cs;
        struct bt_list_head allocated_strings;
+       size_t lineno;
 };
 
 struct ctf_scanner *ctf_scanner_alloc(FILE *input);
This page took 0.026463 seconds and 4 git commands to generate.