Whitespace
[dbsrgits/SQL-Translator.git] / lib / SQL / Translator / Parser / SQLite.pm
index 1024330..0f6b520 100644 (file)
@@ -32,7 +32,7 @@ SQL::Translator::Parser::SQLite - parser for SQLite
 
 =head1 DESCRIPTION
 
-This is a grammar for parsing CREATE statements for SQLite as 
+This is a grammar for parsing CREATE statements for SQLite as
 described here:
 
     http://www.sqlite.org/lang.html
@@ -40,7 +40,7 @@ described here:
 CREATE INDEX
 
 sql-statement ::=
-    CREATE [TEMP | TEMPORARY] [UNIQUE] INDEX index-name 
+    CREATE [TEMP | TEMPORARY] [UNIQUE] INDEX index-name
      ON [database-name .] table-name ( column-name [, column-name]* )
      [ ON CONFLICT conflict-algorithm ]
 
@@ -94,19 +94,19 @@ sql-statement ::=
     trigger-action
 
 database-event ::=
-    DELETE | 
-    INSERT | 
-    UPDATE | 
+    DELETE |
+    INSERT |
+    UPDATE |
     UPDATE OF column-list
 
 trigger-action ::=
-    [ FOR EACH ROW | FOR EACH STATEMENT ] [ WHEN expression ] 
-        BEGIN 
+    [ FOR EACH ROW | FOR EACH STATEMENT ] [ WHEN expression ]
+        BEGIN
             trigger-step ; [ trigger-step ; ]*
         END
 
 trigger-step ::=
-    update-statement | insert-statement | 
+    update-statement | insert-statement |
     delete-statement | select-statement
 
 CREATE VIEW
@@ -167,19 +167,19 @@ $::RD_HINT   = 1; # Give out hints to help fix problems.
 
 $GRAMMAR = q!
 
-{ 
+{
     my ( %tables, $table_order, @table_comments, @views, @triggers );
 }
 
 #
 # The "eofile" rule makes the parser fail if any "statement" rule
-# fails.  Otherwise, the first successful match by a "statement" 
+# fails.  Otherwise, the first successful match by a "statement"
 # won't cause the failure needed to know that the parse, as a whole,
 # failed. -ky
 #
-startrule : statement(s) eofile { 
+startrule : statement(s) eofile {
     $return      = {
-        tables   => \%tables, 
+        tables   => \%tables,
         views    => \@views,
         triggers => \@triggers,
     }
@@ -214,7 +214,7 @@ comment : /^\s*(?:#|-{2}).*\n/
         $return     = $comment;
     }
 
-comment : /\/\*/ /[^\*]+/ /\*\// 
+comment : /\/\*/ /[^\*]+/ /\*\//
     {
         my $comment = $item[2];
         $comment    =~ s/^\s*|\s*$//g;
@@ -229,7 +229,7 @@ create : CREATE TEMPORARY(?) UNIQUE(?) INDEX NAME ON table_name parens_field_lis
         my $db_name    = $item[7]->{'db_name'} || '';
         my $table_name = $item[7]->{'name'};
 
-        my $index        =  { 
+        my $index        =  {
             name         => $item[5],
             fields       => $item[8],
             on_conflict  => $item[9][0],
@@ -269,7 +269,7 @@ create : CREATE TEMPORARY(?) TABLE table_name '(' definition(s /,/) ')' SEMICOLO
         }
     }
 
-definition : constraint_def | column_def 
+definition : constraint_def | column_def
 
 column_def: comment(s?) NAME type(?) column_constraint_def(s?)
     {
@@ -342,7 +342,7 @@ column_constraint : NOT_NULL conflict_clause(?)
         $return = {
             type        => 'primary_key',
             sort_order  => $item[2][0],
-            on_conflict => $item[2][0], 
+            on_conflict => $item[2][0],
         }
     }
     |
@@ -350,7 +350,7 @@ column_constraint : NOT_NULL conflict_clause(?)
     {
         $return = {
             type        => 'unique',
-            on_conflict => $item[2][0], 
+            on_conflict => $item[2][0],
         }
     }
     |
@@ -359,7 +359,7 @@ column_constraint : NOT_NULL conflict_clause(?)
         $return = {
             type        => 'check',
             expression  => $item[3],
-            on_conflict => $item[5][0], 
+            on_conflict => $item[5][0],
         }
     }
     |
@@ -449,11 +449,11 @@ ref_def : /(\w+)\s*\((\w+)\)/
     { $return = { reference_table => $1, reference_fields => $2 } }
 
 table_name : qualified_name
-    
-qualified_name : NAME 
+
+qualified_name : NAME
     { $return = { name => $item[1] } }
 
-qualified_name : /(\w+)\.(\w+)/ 
+qualified_name : /(\w+)\.(\w+)/
     { $return = { db_name => $1, name => $2 } }
 
 field_name : NAME
@@ -525,7 +525,7 @@ for_each : /FOR EACH ROW/i
 when : WHEN expr { $item[2] }
 
 string :
-   /'(\\.|''|[^\\\'])*'/ 
+   /'(\\.|''|[^\\\'])*'/
 
 nonstring : /[^;\'"]+/
 
@@ -534,7 +534,7 @@ statement_body : string | nonstring
 trigger_step : /(select|delete|insert|update)/i statement_body(s?) SEMICOLON
     {
         $return = join( ' ', $item[1], join ' ', @{ $item[2] || [] } )
-    }   
+    }
 
 before_or_after : /(before|after)/i { $return = lc $1 }
 
@@ -549,11 +549,11 @@ trigger_name : qualified_name
 #
 # Create View
 #
-create : CREATE TEMPORARY(?) VIEW view_name AS select_statement 
+create : CREATE TEMPORARY(?) VIEW view_name AS select_statement
     {
         push @views, {
             name         => $item[4]->{'name'},
-            sql          => $item[6], 
+            sql          => $item[6],
             is_temporary => $item[2][0] ? 1 : 0,
         }
     }
@@ -618,9 +618,9 @@ NAME : /["']?(\w+)["']?/ { $return = $1 }
 
 VALUE : /[-+]?\.?\d+(?:[eE]\d+)?/
     { $item[1] }
-    | /'.*?'/   
-    { 
-        # remove leading/trailing quotes 
+    | /'.*?'/
+    {
+        # remove leading/trailing quotes
         my $val = $item[1];
         $val    =~ s/^['"]|['"]$//g;
         $return = $val;
@@ -650,15 +650,15 @@ sub parse {
     warn Dumper( $result ) if $DEBUG;
 
     my $schema = $translator->schema;
-    my @tables = 
+    my @tables =
         map   { $_->[1] }
-        sort  { $a->[0] <=> $b->[0] } 
+        sort  { $a->[0] <=> $b->[0] }
         map   { [ $result->{'tables'}{ $_ }->{'order'}, $_ ] }
         keys %{ $result->{'tables'} };
 
     for my $table_name ( @tables ) {
         my $tdata =  $result->{'tables'}{ $table_name };
-        my $table =  $schema->add_table( 
+        my $table =  $schema->add_table(
             name  => $tdata->{'name'},
         ) or die $schema->error;
 
@@ -700,9 +700,9 @@ sub parse {
                 reference_table  => $cdata->{'reference_table'},
                 reference_fields => $cdata->{'reference_fields'},
                 match_type       => $cdata->{'match_type'} || '',
-                on_delete        => $cdata->{'on_delete'} 
+                on_delete        => $cdata->{'on_delete'}
                                  || $cdata->{'on_delete_do'},
-                on_update        => $cdata->{'on_update'} 
+                on_update        => $cdata->{'on_update'}
                                  || $cdata->{'on_update_do'},
             ) or die $table->error;
         }