texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

texinfo/tp Texinfo/Parser.pm t/27float.t t/resu...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Parser.pm t/27float.t t/resu...
Date: Fri, 29 Oct 2010 19:58:40 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/10/29 19:58:40

Modified files:
        tp/Texinfo     : Parser.pm 
Added files:
        tp/t           : 27float.t 
        tp/t/results/float: empty_listoffloats.pl 
                            listoffloats_with_commands.pl 

Log message:
        Parse listoffloats.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.121&r2=1.122
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/27float.t?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/float/empty_listoffloats.pl?cvsroot=texinfo&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/float/listoffloats_with_commands.pl?cvsroot=texinfo&rev=1.1

Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -b -r1.121 -r1.122
--- Texinfo/Parser.pm   29 Oct 2010 19:31:15 -0000      1.121
+++ Texinfo/Parser.pm   29 Oct 2010 19:58:39 -0000      1.122
@@ -1592,6 +1592,24 @@
   return $result;
 }
 
+sub _parse_float_type($)
+{
+  my $current = shift;
+  if (@{$current->{'args'}}) {
+    my @type_contents = @{$current->{'args'}->[0]->{'contents'}};
+    _trim_spaces_comment_from_content(address@hidden);
+    if (@type_contents) {
+      my $normalized = 
Texinfo::Convert::NodeNameNormalization::convert({'contents' => address@hidden);
+      if ($normalized =~ /\S/) {
+        $current->{'special'}->{'type'}->{'normalized'} = $normalized;
+        $current->{'special'}->{'type'}->{'content'} = address@hidden;
+        return 1;
+      }
+    }
+  }
+  return 0;
+}
+
 # used for definition line parsing
 sub _next_bracketed_or_word($)
 {
@@ -1882,13 +1900,7 @@
             $float->{'special'}->{'label'} = $float_label;
           }
         }
-        my @type_contents = @{$float->{'args'}->[0]->{'contents'}};
-        _trim_spaces_comment_from_content(address@hidden);
-        if (@type_contents) {
-          $float->{'special'}->{'type'}->{'normalized'} 
-            = Texinfo::Convert::NodeNameNormalization::convert({'contents' => 
address@hidden);
-          $float->{'special'}->{'type'}->{'content'} = address@hidden;
-        }
+        _parse_float_type ($float);
       }
     }
     $current = $current->{'parent'};
@@ -1998,6 +2010,12 @@
       }
       _check_node_label($self, $current->{'extra'}->{'nodes_manuals'}->[0],
                         $current->{'args'}->[0], $command, $line_nr);
+    } elsif ($command eq 'listoffloats') {
+      my $empty_listoffloats = 1;
+      if (!_parse_float_type($current)) {
+        _line_error ($self, sprintf($self->__("address@hidden missing 
argument"), 
+           $command), $line_nr);
+      }
     }
     $current = $current->{'parent'};
     # if a file was included, remove completly the include file command.

Index: t/27float.t
===================================================================
RCS file: t/27float.t
diff -N t/27float.t
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/27float.t 29 Oct 2010 19:58:40 -0000      1.1
@@ -0,0 +1,18 @@
+use strict;
+
+require 't/test_utils.pl';
+
+my @test_cases = (
+['listoffloats_with_commands',
+'@listoffloats address@hidden'address@hidden
+'],
+['empty_listoffloats',
+'@listoffloats
+']
+);
+
+our ($arg_test_case, $arg_generate, $arg_debug);
+
+run_all ('float', address@hidden, $arg_test_case,
+   $arg_generate, $arg_debug);
+

Index: t/results/float/empty_listoffloats.pl
===================================================================
RCS file: t/results/float/empty_listoffloats.pl
diff -N t/results/float/empty_listoffloats.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/float/empty_listoffloats.pl       29 Oct 2010 19:58:40 -0000      
1.1
@@ -0,0 +1,54 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
%results_indices);
+
+$result_trees{'empty_listoffloats'} = {
+  'contents' => [
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'empty_line_after_command'
+            }
+          ],
+          'parent' => {},
+          'type' => 'misc_line_arg'
+        }
+      ],
+      'cmdname' => 'listoffloats',
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 1,
+        'macro' => ''
+      },
+      'parent' => {}
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'empty_listoffloats'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'empty_listoffloats'}{'contents'}[0]{'args'}[0];
+$result_trees{'empty_listoffloats'}{'contents'}[0]{'args'}[0]{'parent'} = 
$result_trees{'empty_listoffloats'}{'contents'}[0];
+$result_trees{'empty_listoffloats'}{'contents'}[0]{'parent'} = 
$result_trees{'empty_listoffloats'};
+
+$result_texis{'empty_listoffloats'} = '@listoffloats
+';
+
+
+$result_texts{'empty_listoffloats'} = '';
+
+$result_errors{'empty_listoffloats'} = [
+  {
+    'error_line' => ':1: @listoffloats missing argument
+',
+    'file_name' => '',
+    'line_nr' => 1,
+    'macro' => '',
+    'text' => '@listoffloats missing argument',
+    'type' => 'error'
+  }
+];
+
+
+1;

Index: t/results/float/listoffloats_with_commands.pl
===================================================================
RCS file: t/results/float/listoffloats_with_commands.pl
diff -N t/results/float/listoffloats_with_commands.pl
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ t/results/float/listoffloats_with_commands.pl       29 Oct 2010 19:58:40 
-0000      1.1
@@ -0,0 +1,106 @@
+use vars qw(%result_texis %result_texts %result_trees %result_errors 
%results_indices);
+
+$result_trees{'listoffloats_with_commands'} = {
+  'contents' => [
+    {
+      'args' => [
+        {
+          'contents' => [
+            {
+              'parent' => {},
+              'text' => ' ',
+              'type' => 'empty_spaces_after_command'
+            },
+            {
+              'parent' => {},
+              'text' => 'th'
+            },
+            {
+              'args' => [
+                {
+                  'parent' => {},
+                  'text' => 'e'
+                }
+              ],
+              'cmdname' => '\'',
+              'parent' => {}
+            },
+            {
+              'parent' => {},
+              'text' => 'or'
+            },
+            {
+              'args' => [
+                {
+                  'parent' => {},
+                  'text' => 'e'
+                }
+              ],
+              'cmdname' => '`',
+              'parent' => {}
+            },
+            {
+              'parent' => {},
+              'text' => 'me'
+            },
+            {
+              'parent' => {},
+              'text' => '
+',
+              'type' => 'spaces_at_end'
+            }
+          ],
+          'parent' => {},
+          'type' => 'misc_line_arg'
+        }
+      ],
+      'cmdname' => 'listoffloats',
+      'line_nr' => {
+        'file_name' => '',
+        'line_nr' => 1,
+        'macro' => ''
+      },
+      'parent' => {},
+      'special' => {
+        'type' => {
+          'content' => [
+            {},
+            {},
+            {},
+            {},
+            {}
+          ],
+          'normalized' => 'th_00e9or_00e8me'
+        }
+      }
+    }
+  ],
+  'type' => 'text_root'
+};
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[0]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[1]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[2]{'args'}[0]{'parent'}
 = 
$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[2]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[3]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[4]{'args'}[0]{'parent'}
 = 
$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[4];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[4]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[5]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[6]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'parent'}
 = $result_trees{'listoffloats_with_commands'}{'contents'}[0];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'parent'} = 
$result_trees{'listoffloats_with_commands'};
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'special'}{'type'}{'content'}[0]
 = 
$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[1];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'special'}{'type'}{'content'}[1]
 = 
$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[2];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'special'}{'type'}{'content'}[2]
 = 
$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[3];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'special'}{'type'}{'content'}[3]
 = 
$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[4];
+$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'special'}{'type'}{'content'}[4]
 = 
$result_trees{'listoffloats_with_commands'}{'contents'}[0]{'args'}[0]{'contents'}[5];
+
+$result_texis{'listoffloats_with_commands'} = '@listoffloats 
address@hidden'address@hidden
+';
+
+
+$result_texts{'listoffloats_with_commands'} = '';
+
+$result_errors{'listoffloats_with_commands'} = [];
+
+
+1;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]