projects
/
dbsrgits/SQL-Translator.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
(parent:
c96cd4a
)
better error messages for the SQLite parser
Arthur Axel 'fREW' Schmidt [Thu, 14 Jul 2011 15:40:27 +0000 (10:40 -0500)]
lib/SQL/Translator/Parser/SQLite.pm
patch
|
blob
|
blame
|
history
diff --git
a/lib/SQL/Translator/Parser/SQLite.pm
b/lib/SQL/Translator/Parser/SQLite.pm
index
fc39db7
..
169b516
100644
(file)
--- a/
lib/SQL/Translator/Parser/SQLite.pm
+++ b/
lib/SQL/Translator/Parser/SQLite.pm
@@
-152,6
+152,16
@@
$GRAMMAR = q!
{
my ( %tables, $table_order, @table_comments, @views, @triggers );
+
+ sub _err {
+ my $max_lines = 5;
+ my @up_to_N_lines = split (/\n/, $_[1], $max_lines + 1);
+ die sprintf ("Unable to parse line %d:\n%s\n",
+ $_[0],
+ join "\n", (map { "'$_'" } @up_to_N_lines[0..$max_lines - 1 ]), @up_to_N_lines > $max_lines ? '...' : ()
+ );
+ }
+
}
#
@@
-175,7
+185,7
@@
statement : begin_transaction
| drop
| comment
| create
- | <error>
+ | /^\Z/ | { _err ($thisline, $text) }
begin_transaction : /begin/i TRANSACTION(?) SEMICOLON