]> granicus.if.org Git - re2c/commitdiff
Fixed #147 "Please add symbol name to "can't find symbol" error message".
authorUlya Trofimovich <skvadrik@gmail.com>
Sat, 25 Jun 2016 15:22:08 +0000 (16:22 +0100)
committerUlya Trofimovich <skvadrik@gmail.com>
Sat, 25 Jun 2016 16:09:42 +0000 (17:09 +0100)
As suggested by sirzooro:
    Please add symbol name to "can't find symbol" error message,
    it would allow to quickly spot what is wrong. Now we have to
    position cursor at given row and column to find that name.

Also tweaked error reporitng function to append "..." at the end
of the message if it didn't fit into buffer.

re2c/bootstrap/src/parse/lex.cc
re2c/bootstrap/src/parse/parser.cc
re2c/src/parse/parser.ypp
re2c/src/parse/scanner.cc
re2c/test/bug147.c [new file with mode: 0644]
re2c/test/bug147.re [new file with mode: 0644]
re2c/test/overflow-2.c
re2c/test/overflow-3.c

index 2740a37dae977e7e10ae8714973fc863e597a39f..27a90ace6b495a8bc19d9f667b320d3040a8f0c0 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.16 on Fri Jun 24 22:37:48 2016 */
+/* Generated by re2c 0.16 on Sat Jun 25 16:16:23 2016 */
 #line 1 "../src/parse/lex.re"
 #include "src/util/c99_stdint.h"
 #include <stddef.h>
index 4d58acadae7adbe02e19ae3f9d25fed4858df3fa..f277eed4636b15275461c6ae3a68a3d4ddb24ac4 100644 (file)
@@ -2006,11 +2006,11 @@ yyreduce:
 
     {
                        symbol_table_t::iterator i = symbol_table.find (* (yyvsp[(1) - (1)].str));
-                       delete (yyvsp[(1) - (1)].str);
                        if (i == symbol_table.end ())
                        {
-                               in->fatal("can't find symbol");
+                               in->fatalf("'%s' is not defined", (yyvsp[(1) - (1)].str)->c_str());
                        }
+                       delete (yyvsp[(1) - (1)].str);
                        (yyval.regexp) = i->second;
                ;}
     break;
index d1877280a2cabe06507e2a039cbb5567697dc094..aaae3c1e20a69ba26ed41fae33a44144c1611f9a 100644 (file)
@@ -536,11 +536,11 @@ primary:
                TOKEN_ID
                {
                        symbol_table_t::iterator i = symbol_table.find (* $1);
-                       delete $1;
                        if (i == symbol_table.end ())
                        {
-                               in->fatal("can't find symbol");
+                               in->fatalf("'%s' is not defined", $1->c_str());
                        }
+                       delete $1;
                        $$ = i->second;
                }
        |       TOKEN_REGEXP
index 09dd2bda4b2e790e813adad096a210c54547f145..e7f5375e90ac2008731f1d9aed35c0cf654927a2 100644 (file)
@@ -159,17 +159,19 @@ void Scanner::fatalf_at(uint32_t line, const char* fmt, ...) const
 
 void Scanner::fatalf(const char *fmt, ...) const
 {
-       char szBuf[4096];
+       static const char tail[] = "...";
+       static const size_t TAIL = sizeof(tail);
+       static const size_t MAX = 4096;
+       char msg[MAX + TAIL];
 
        va_list args;
-       
        va_start(args, fmt);
-       vsnprintf(szBuf, sizeof(szBuf), fmt, args);
+       vsnprintf(msg, MAX, fmt, args);
        va_end(args);
-       
-       szBuf[sizeof(szBuf)-1] = '0';
-       
-       fatal(szBuf);
+
+       sprintf(&msg[MAX - 1], tail);
+
+       fatal(msg);
 }
 
 Scanner::~Scanner()
diff --git a/re2c/test/bug147.c b/re2c/test/bug147.c
new file mode 100644 (file)
index 0000000..7c3f3f2
--- /dev/null
@@ -0,0 +1 @@
+re2c: error: line 2, column 11: 'name1' is not defined
diff --git a/re2c/test/bug147.re b/re2c/test/bug147.re
new file mode 100644 (file)
index 0000000..5d9eff3
--- /dev/null
@@ -0,0 +1,3 @@
+/*!re2c
+    name1 {}
+*/
index 6e170e14d3f98112e1630bfce6eb9930b49d189f..ff07d21ea615301ac11d0cba1d4891908de5932c 100644 (file)
@@ -1 +1 @@
-re2c: error: line 2, column 8219: can't find symbol
+re2c: error: line 2, column 8219: 'x0000_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00040_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00080_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaa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aaaaaa_x00D40_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00D80_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00DC0_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00E00_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00E40_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00E80_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00EC0_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00F00_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00F40_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00F80_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00FC0_4th_KByte_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa...
index 6e170e14d3f98112e1630bfce6eb9930b49d189f..ff07d21ea615301ac11d0cba1d4891908de5932c 100644 (file)
@@ -1 +1 @@
-re2c: error: line 2, column 8219: can't find symbol
+re2c: error: line 2, column 8219: 'x0000_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00040_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x00080_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaaa_aaaaaaaaaaaaaa_x000C0_aaaaaaaaa_aaaaaaaaaaaaaaa_aaaaa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