texinfo-commits
[Top][All Lists]
Advanced

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

texinfo/tp Texinfo/Parser.pm Texinfo/Structurin...


From: Patrice Dumas
Subject: texinfo/tp Texinfo/Parser.pm Texinfo/Structurin...
Date: Tue, 19 Oct 2010 09:39:37 +0000

CVSROOT:        /sources/texinfo
Module name:    texinfo
Changes by:     Patrice Dumas <pertusus>        10/10/19 09:39:37

Modified files:
        tp/Texinfo     : Parser.pm Structuring.pm 
        tp/t           : test_utils.pl 
        tp/t/results/macro: macro_in_index_commands.pl 
        tp/t/results/value: value_in_index_commands.pl 

Log message:
        Parse printindex argument.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.82&r2=1.83
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Structuring.pm?cvsroot=texinfo&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/test_utils.pl?cvsroot=texinfo&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/macro/macro_in_index_commands.pl?cvsroot=texinfo&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/value/value_in_index_commands.pl?cvsroot=texinfo&r1=1.4&r2=1.5

Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -b -r1.82 -r1.83
--- Texinfo/Parser.pm   18 Oct 2010 22:44:06 -0000      1.82
+++ Texinfo/Parser.pm   19 Oct 2010 09:39:36 -0000      1.83
@@ -105,9 +105,9 @@
   # number of arguments is not known in advance.
   'columnfractions'  => 1, 
   # file names
-  'setfilename'      => 'line',
-  'verbatiminclude'  => 'line',
-  'include'          => 'line',
+  'setfilename'       => 'text',
+  'verbatiminclude'   => 'text',
+  'include'           => 'text',
 
   'raisesections'    => 'skipline',  # no arg
   'lowersections'    => 'skipline', # no arg
@@ -117,11 +117,11 @@
   'insertcopying'    => 'noarg', # no arg
   'clickstyle'       => 'special', # arg should be an @-command
   # more relevant in preamble
-  'documentencoding'  => 'line', # or 1?
   'setcontentsaftertitlepage' => 'skipline', # no arg
   'setshortcontentsaftertitlepage' => 'skipline', # no arg
+  'documentencoding'  => 'text', # or 1?
   'novalidate'        => 'skipline', # no arg
-  'dircategory'       => 'line', # line. Position with regard 
+  'dircategory'       => 'text', # line. Position with regard 
                                  # with direntry is significant
   'pagesizes'         => 'line', # can have 2 args 
                            # or one? 200mm,150mm 11.5in
@@ -156,11 +156,8 @@
   'synindex'     => 2,
   'defindex'     => 1, # one identifier arg
   'defcodeindex' => 1, # one identifier arg
-  #'documentlanguage' => {'skip' => 'line', 'arg' => 1},
-  'documentlanguage'  => 'line',
-                                                 # language code arg
-  'kbdinputstyle'     => 1, # code 
-                                                  #example distinct
+  'documentlanguage'  => 'text',     # language code arg
+  'kbdinputstyle'     => 1,          # code example distinct
   'everyheadingmarks' => 1, # top bottom
   'everyfootingmarks' => 1,
   'evenheadingmarks'  => 1,
@@ -172,9 +169,8 @@
 
   # formatting
   'center'            => 'line',
-  # FIXME, line or arg? Verify the index exists?
-  'printindex'        => 'line',
-  #'printindex' => {'arg' => 1, 'skip' => 'line'},
+  # FIXME Verify the index exists?
+  'printindex'        => 1,
   'listoffloats'      => 'line',
   # especially in titlepage
   'shorttitle'        => 'line',
@@ -2696,6 +2692,15 @@
     } else {
       _line_error ($self, sprintf($self->__("Bad argument to address@hidden: 
%s"), $command, $line), $line_nr);
     }
+  } elsif ($command eq 'printindex') {
+    # REMACRO
+    if ($line =~ /^([[:alnum:]][[:alnum:]\-]*)\s*/) {
+      my $name = $1;
+      $args = [$name];
+    } else {
+      _line_error ($self, sprintf($self->
+                   __("Bad argument to address@hidden: %s"), $command, $line), 
$line_nr);
+    }
   } elsif (grep {$_ eq $command} ('everyheadingmarks', 'everyfootingmarks',
                                   'evenheadingmarks', 'oddheadingmarks',
                                   'evenfootingmarks', 'oddfootingmarks')) {

Index: Texinfo/Structuring.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Structuring.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- Texinfo/Structuring.pm      18 Oct 2010 22:47:57 -0000      1.1
+++ Texinfo/Structuring.pm      19 Oct 2010 09:39:36 -0000      1.2
@@ -71,7 +71,7 @@
     while ($current->{'parent'} and !$current->{'parent'}->{'next'}) {
       $current = $current->{'parent'};
     }
-    if ($current->{'parent'}->{'next'}) {
+    if ($current->{'parent'} and $current->{'parent'}->{'next'}) {
       $current = $current->{'parent'}->{'next'}
     } else {
       $current = undef;

Index: t/test_utils.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/test_utils.pl,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- t/test_utils.pl     17 Oct 2010 13:43:42 -0000      1.21
+++ t/test_utils.pl     19 Oct 2010 09:39:37 -0000      1.22
@@ -43,6 +43,9 @@
   return $test;
 }
 
+sub filter_keys { [grep {$_ ne 'next'} ( sort keys %{$_[0]} )] }
+#sub filter_keys { [grep {$_ ne 'parent' and $_ ne 'next'} ( sort keys 
%{$_[0]} )] }
+
 sub test($$) 
 {
   my $self = shift;
@@ -70,6 +73,8 @@
   } else {
     $result = $parser->parse_texi_file($test_case);
   }
+#use Texinfo::Structuring;
+#Texinfo::Structuring::collect_structure($result);
 
   my ($errors, $error_nrs) = $parser->errors();
   my $converted_text = Texinfo::Convert::Text::convert($result);
@@ -79,7 +84,7 @@
 
   {
     local $Data::Dumper::Purity = 1;
-    local $Data::Dumper::Sortkeys = 1;
+    local $Data::Dumper::Sortkeys = \&filter_keys;
     local $Data::Dumper::Indent = 1;
 
     my $out_file = $new_file;
@@ -116,10 +121,10 @@
 
     #$transformer->traverse($result_trees{$test_name});
     #$transformer->traverse($result);
-    {
+    #{
       #local $Data::Dumper::Purity = 1;
-      local $Data::Dumper::Sortkeys = 1;
-      local $Data::Dumper::Indent = 1;
+      #local $Data::Dumper::Sortkeys = 1;
+      #local $Data::Dumper::Indent = 1;
       #if (!Struct::Compare::compare($result, $result_trees{$test_name})) {
       #  print STDERR "".Data::Dumper->Dump([$result],['$new']);
       #  print STDERR "".Data::Dumper->Dump([$result_trees{$test_name}], 
['$ref']);
@@ -127,8 +132,8 @@
 
       #my $diff = Data::Diff->new($result, $result_trees{$test_name});
       #print STDERR "".Data::Dumper->Dump([$diff->raw()], ['$diff']);
-    }
-    ok (Data::Compare::Compare($result, $result_trees{$test_name}, { 
'ignore_hash_keys' => [qw(parent)] }), $test_name.' tree' );
+    #}
+    ok (Data::Compare::Compare($result, $result_trees{$test_name}, { 
'ignore_hash_keys' => [qw(parent next)] }), $test_name.' tree' );
     #ok(Struct::Compare::compare($result, $result_trees{$test_name}), 
$test_name.' tree' );
     #ok (Data::Compare::Compare($result, $result_trees{$test_name}), 
$test_name.' tree' );
     ok (Data::Compare::Compare($errors, $result_errors{$test_name}), 
$test_name.' errors' );

Index: t/results/macro/macro_in_index_commands.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/macro/macro_in_index_commands.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- t/results/macro/macro_in_index_commands.pl  18 Oct 2010 22:09:09 -0000      
1.5
+++ t/results/macro/macro_in_index_commands.pl  19 Oct 2010 09:39:37 -0000      
1.6
@@ -1026,7 +1026,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'pg'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1065,7 +1070,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'ky'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1104,7 +1114,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'truc'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1143,7 +1158,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'truc'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1182,7 +1202,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'cp'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1221,7 +1246,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'cp'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1260,7 +1290,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'defg'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1299,7 +1334,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'abc'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1338,7 +1378,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'fn'
+        ]
+      }
     }
   ]
 };

Index: t/results/value/value_in_index_commands.pl
===================================================================
RCS file: 
/sources/texinfo/texinfo/tp/t/results/value/value_in_index_commands.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- t/results/value/value_in_index_commands.pl  17 Oct 2010 10:50:48 -0000      
1.4
+++ t/results/value/value_in_index_commands.pl  19 Oct 2010 09:39:37 -0000      
1.5
@@ -799,7 +799,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'pg'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -838,7 +843,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'ky'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -877,7 +887,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'truc'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -916,7 +931,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'truc'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -955,7 +975,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'cp'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -994,7 +1019,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'cp'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1033,7 +1063,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'defg'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1072,7 +1107,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'abc'
+        ]
+      }
     },
     {
       'parent' => {},
@@ -1111,7 +1151,12 @@
         }
       ],
       'cmdname' => 'printindex',
-      'parent' => {}
+      'parent' => {},
+      'special' => {
+        'misc_args' => [
+          'fn'
+        ]
+      }
     }
   ]
 };



reply via email to

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