[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Parser.pm t/02coverage.t t/m...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Parser.pm t/02coverage.t t/m... |
Date: |
Sat, 25 Sep 2010 16:01:08 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 10/09/25 16:01:07
Modified files:
tp/Texinfo : Parser.pm
tp/t : 02coverage.t manual_tree.pl
tp/t/results/columnfractions: empty.pl empty_comment.pl good.pl
good_comment.pl
good_space_comment.pl
not_fraction.pl wrong_command.pl
Log message:
Handle content before item for the relevant commands.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/02coverage.t?cvsroot=texinfo&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/manual_tree.pl?cvsroot=texinfo&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/columnfractions/empty.pl?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/columnfractions/empty_comment.pl?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/columnfractions/good.pl?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/columnfractions/good_comment.pl?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/columnfractions/good_space_comment.pl?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/columnfractions/not_fraction.pl?cvsroot=texinfo&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/columnfractions/wrong_command.pl?cvsroot=texinfo&r1=1.3&r2=1.4
Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- Texinfo/Parser.pm 25 Sep 2010 14:33:35 -0000 1.15
+++ Texinfo/Parser.pm 25 Sep 2010 16:01:07 -0000 1.16
@@ -136,6 +136,9 @@
# Value is either the number of arguments on the line separated by
# commas or the type of command, 'raw', 'def' or 'multitable'.
my %block_commands;
+
+# commands that have a possible content before an item
+my %block_item_commands;
foreach my $bracketed_line_argument_command(#'multitable',
'deffn',
'defvr',
@@ -163,6 +166,7 @@
}
$block_commands{'multitable'} = 'multitable';
+$block_item_commands{'multitable'} = 1;
foreach my $block_command(
'menu', 'detailmenu', 'direntry',
@@ -189,8 +193,12 @@
foreach my $block_command_one_arg('table', 'ftable', 'vtable',
'itemize', 'enumerate', 'quotation', 'small_quotation') {
$block_commands{$block_command_one_arg} = 1;
+ $block_item_commands{$block_command_one_arg} = 1
+ unless ($block_command_one_arg =~ /quotation/);
}
+
+
$block_commands{'float'} = 2;
my %item_container_commands;
@@ -634,7 +642,7 @@
my $self = shift;
my $current = shift;
- if ((!$current->{'type'} or $current->{'type'} eq 'container')
+ if ((!$current->{'type'} or $current->{'type'} eq 'before_item')
and !$no_paragraph_contexts{$self->{'context'}->[-1]}) {
push @{$current->{'contents'}},
{ 'type' => 'paragraph', 'parent' => $current, 'contents' => [] };
@@ -769,8 +777,8 @@
sub _item_container_parent($)
{
my $current = shift;
- if (($current->{'cmdname'} and $current->{'cmdname'} eq 'item'
- or $current->{'type'} and $current->{'type'} eq 'container')
+ if ((($current->{'cmdname'} and $current->{'cmdname'} eq 'item')
+ or ($current->{'type'} and $current->{'type'} eq 'before_item'))
and ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
and $item_container_commands{$current->{'parent'}->{'cmdname'}})) {
return ($current->{'parent'});
@@ -783,7 +791,7 @@
my $current = shift;
if (($current->{'cmdname'} and $current->{'cmdname'} eq 'item'
or $current->{'cmdname'} eq 'itemx'
- or $current->{'type'} and $current->{'type'} eq 'container')
+ or $current->{'type'} and $current->{'type'} eq 'before_item')
and ($current->{'parent'} and $current->{'parent'}->{'cmdname'}
and $item_line_commands{$current->{'parent'}->{'cmdname'}})) {
return ($current->{'parent'});
@@ -798,7 +806,7 @@
or $current->{'cmdname'} eq 'item' or $current->{'cmdname'} eq 'tab')
and $current->{'parent'} and $current->{'parent'}->{'parent'}) {
$current = $current->{'parent'}->{'parent'};
- } elsif ($current->{'type'} and $current->{'type'} eq 'container'
+ } elsif ($current->{'type'} and $current->{'type'} eq 'before_item'
and $current->{'parent'}) {
$current = $current->{'parent'};
}
@@ -823,7 +831,7 @@
#
#c 'brace_command_arg'
#
-#c 'container' FIXME what comes after @*table, @itemize, @enumerate before
+#c 'before_item' FIXME what comes after @*table, @itemize, @enumerate before
# an @item
#
#c 'paragraph'
@@ -1009,6 +1017,7 @@
# itemize or enumerate
if ($parent = _item_container_parent($current)) {
if ($command eq 'item') {
+ print STDERR "ITEM_CONTAINER\n" if ($self->{'debug'});
push @{$parent->{'contents'}},
{ 'cmdname' => $command, 'parent' => $parent,
'contents' => [] };
@@ -1019,6 +1028,7 @@
# *table
} elsif ($parent = _item_line_parent($current)) {
if ($command eq 'item' or $command eq 'itemx') {
+ print STDERR "ITEM_LINE\n";
push @{$current->{'contents'}},
{ 'cmdname' => $command, 'parent' => $current };
$line_arg = $line;
@@ -1034,7 +1044,7 @@
} elsif ($command eq 'tab') {
my $row = $parent->{'contents'}->[-1];
die if (!$row->{'type'});
- if ($row->{'type'} eq 'container') {
+ if ($row->{'type'} eq 'before_item') {
$self->_line_warn($self->__("address@hidden before
address@hidden"), $line_nr);
} elsif ($row->{'special'}->{'cell_number'} >
$parent->{'special'}->{'max_columns'}) {
return undef if $self->_line_error (sprintf($self->__("Too
many columns in multitable item (max %d)"),
$parent->{'special'}->{'max_columns'}), $line_nr);
@@ -1043,8 +1053,10 @@
push @{$row->{'contents'}}, { 'cmdname' => $command,
'parent' => $row };
$current = $row->{'contents'}->[-1];
+ print STDERR "TAB\n";
}
} else {
+ print STDERR "ROW\n";
my $row = { 'type' => 'row', 'contents' => [],
'special' => { 'cell_number' => 1 },
'parent' => $parent };
@@ -1101,38 +1113,27 @@
'parent' => $current,
'contents' => [] };
$current = $current->{'contents'}->[-1];
- if ($block_commands{$command} and
- $block_commands{$command} =~ /^\d+$/) {
+ my $arg_number = $block_commands{$command}
+ if ($block_commands{$command}
+ and $block_commands{$command} =~ /^\d+$/);
+ if ($arg_number
+ or ($command eq 'multitable')
+ or ($block_commands{$command} eq 'def')) {
$current->{'args'} = [ {
'type' => 'block_line_arg',
'contents' => [],
'parent' => $current } ];
- $current->{'remaining_args'} = $block_commands{$command} -1;
- $current = $current->{'args'}->[-1];
- } elsif ($command eq 'multitable') {
- if ($line =~ s/address@hidden//) {
- # both a cmdname and block_line_arg
- $current->{'args'} = [ { 'cmdname' => 'columnfractions',
- 'type' => 'block_line_arg',
- 'parent' => $current,
- 'contents' => [] } ];
- $current = $current->{'args'}->[-1];
- } else {
- $current->{'sepcial'}->{'max_columns'} = 0;
- $current->{'args'} = [ { 'type' => 'block_line_arg',
- 'parent' => $current,
- 'contents' => [] } ];
+ $current->{'remaining_args'} = $arg_number -1 if ($arg_number);
$current = $current->{'args'}->[-1];
+ if ($command eq 'multitable'
+ and $line =~ s/address@hidden//) {
+ # both an argument and an @-command
+ $current->{'cmdname'} = 'columnfractions';
}
- } elsif ($block_commands{$command} eq 'def') {
- $current->{'args'} = [ { 'type' => 'block_line_arg',
- 'parent' => $current,
- 'contents' => [] } ];
- $current = $current->{'args'}->[-1];
- #push @{$self->{'context'}}, 'def';
- } elsif ($preformatted_commands{$command}) {
- push @{$self->{'context'}}, 'preformatted';
+ #push @{$self->{'context'}}, 'def' if ($block_commands{$command}
eq 'def');
} else {
+ push @{$self->{'context'}}, 'preformatted'
+ if ($preformatted_commands{$command});
last unless ($line =~ /\S/);
}
}
@@ -1356,6 +1357,12 @@
}
}
$current = $current->{'parent'};
+ if ($current->{'cmdname'}
+ and $block_item_commands{$current->{'cmdname'}}) {
+ push @{$current->{'contents'}}, { 'type' => 'before_item',
+ 'contents' => [], 'parent', $current };
+ $current = $current->{'contents'}->[-1];
+ }
}
last;
}
@@ -1453,6 +1460,10 @@
}
#die "Shouldn't have args: $cmd->{'cmdname'}\n";
$result .= '}' if ($braces);
+ } elsif ($misc_commands{$cmd->{'cmdname'}}
+ and $misc_commands{$cmd->{'cmdname'}}->{'skip'}
+ and $misc_commands{$cmd->{'cmdname'}}->{'skip'} eq 'space') {
+ $result .= ' ';
}
if (defined($block_commands{$cmd->{'cmdname'}})) {
# there is an end of line if there is a comment, for example
@@ -1475,11 +1486,11 @@
my $skip_spec = '';
my $arg_spec = '';
-#print STDERR "HHHHHHHHH $line $command\n";
$skip_spec = $self->{'misc_commands'}->{$command}->{'skip'}
- if (defined($self->{'misc_commands'}->{'skip'}));
- $arg_spec = $misc_commands{$command}->{'arg'}
- if (defined($misc_commands{$command}->{'arg'}));
+ if (defined($self->{'misc_commands'}->{$command}->{'skip'}));
+ $arg_spec = $self->{'misc_commands'}->{$command}->{'arg'}
+ if (defined($self->{'misc_commands'}->{$command}->{'arg'}));
+#print STDERR "HHHHHHHHH $line $command arg_spec $arg_spec skip_spec
$skip_spec\n";
if ($command eq 'alias') {
if ($line =~ s/(\s+)([a-zA-Z][\w-]*)(\s*=\s*)([a-zA-Z][\w-]*)(\s*)//) {
Index: t/02coverage.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/02coverage.t,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- t/02coverage.t 25 Sep 2010 14:33:37 -0000 1.6
+++ t/02coverage.t 25 Sep 2010 16:01:07 -0000 1.7
@@ -28,18 +28,20 @@
in caption}
@end float
-'],);
-my @todo = (
+'],
['item_container','
@itemize +
@item i--tem +
@end itemize
-
address@hidden @bullet
address@hidden
- b--ullet
address@hidden itemize
-'],
+']
+#
address@hidden @bullet
address@hidden
+# b--ullet
address@hidden itemize
+#'],
+);
+my @todo = (
['table','
@table asis
@item table item
Index: t/manual_tree.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/manual_tree.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
Index: t/results/columnfractions/empty.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/columnfractions/empty.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/columnfractions/empty.pl 25 Sep 2010 14:33:38 -0000 1.3
+++ t/results/columnfractions/empty.pl 25 Sep 2010 16:01:07 -0000 1.4
@@ -10,8 +10,14 @@
}
],
'cmdname' => 'multitable',
+ 'contents' => [
+ {
'contents' => [],
'parent' => {},
+ 'type' => 'before_item'
+ }
+ ],
+ 'parent' => {},
'special' => {
'max_columns' => 0
}
@@ -19,6 +25,7 @@
]
};
$result_trees{'empty'}{'contents'}[0]{'args'}[0]{'parent'} =
$result_trees{'empty'}{'contents'}[0];
+$result_trees{'empty'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'empty'}{'contents'}[0];
$result_trees{'empty'}{'contents'}[0]{'parent'} = $result_trees{'empty'};
$result_texts{'empty'} = '@multitable @columnfractions
Index: t/results/columnfractions/empty_comment.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/columnfractions/empty_comment.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/columnfractions/empty_comment.pl 25 Sep 2010 14:33:39 -0000
1.3
+++ t/results/columnfractions/empty_comment.pl 25 Sep 2010 16:01:07 -0000
1.4
@@ -22,8 +22,14 @@
}
],
'cmdname' => 'multitable',
+ 'contents' => [
+ {
'contents' => [],
'parent' => {},
+ 'type' => 'before_item'
+ }
+ ],
+ 'parent' => {},
'special' => {
'max_columns' => 0
}
@@ -33,6 +39,7 @@
$result_trees{'empty_comment'}{'contents'}[0]{'args'}[0]{'parent'} =
$result_trees{'empty_comment'}{'contents'}[0];
$result_trees{'empty_comment'}{'contents'}[0]{'args'}[1]{'args'}[0]{'parent'}
= $result_trees{'empty_comment'}{'contents'}[0]{'args'}[1];
$result_trees{'empty_comment'}{'contents'}[0]{'args'}[1]{'parent'} =
$result_trees{'empty_comment'}{'contents'}[0];
+$result_trees{'empty_comment'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'empty_comment'}{'contents'}[0];
$result_trees{'empty_comment'}{'contents'}[0]{'parent'} =
$result_trees{'empty_comment'};
$result_texts{'empty_comment'} = '@multitable @columnfractions @c
Index: t/results/columnfractions/good.pl
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/results/columnfractions/good.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/columnfractions/good.pl 25 Sep 2010 14:33:39 -0000 1.3
+++ t/results/columnfractions/good.pl 25 Sep 2010 16:01:07 -0000 1.4
@@ -27,8 +27,14 @@
}
],
'cmdname' => 'multitable',
+ 'contents' => [
+ {
'contents' => [],
'parent' => {},
+ 'type' => 'before_item'
+ }
+ ],
+ 'parent' => {},
'special' => {
'max_columns' => 3
}
@@ -39,6 +45,7 @@
$result_trees{'good'}{'contents'}[0]{'args'}[0]{'args'}[1]{'parent'} =
$result_trees{'good'}{'contents'}[0]{'args'}[0];
$result_trees{'good'}{'contents'}[0]{'args'}[0]{'args'}[2]{'parent'} =
$result_trees{'good'}{'contents'}[0]{'args'}[0];
$result_trees{'good'}{'contents'}[0]{'args'}[0]{'parent'} =
$result_trees{'good'}{'contents'}[0];
+$result_trees{'good'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'good'}{'contents'}[0];
$result_trees{'good'}{'contents'}[0]{'parent'} = $result_trees{'good'};
$result_texts{'good'} = '@multitable @columnfractions 0.4 .6 5.
Index: t/results/columnfractions/good_comment.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/columnfractions/good_comment.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/columnfractions/good_comment.pl 25 Sep 2010 14:33:39 -0000
1.3
+++ t/results/columnfractions/good_comment.pl 25 Sep 2010 16:01:07 -0000
1.4
@@ -39,8 +39,14 @@
}
],
'cmdname' => 'multitable',
+ 'contents' => [
+ {
'contents' => [],
'parent' => {},
+ 'type' => 'before_item'
+ }
+ ],
+ 'parent' => {},
'special' => {
'max_columns' => 3
}
@@ -53,6 +59,7 @@
$result_trees{'good_comment'}{'contents'}[0]{'args'}[0]{'parent'} =
$result_trees{'good_comment'}{'contents'}[0];
$result_trees{'good_comment'}{'contents'}[0]{'args'}[1]{'args'}[0]{'parent'} =
$result_trees{'good_comment'}{'contents'}[0]{'args'}[1];
$result_trees{'good_comment'}{'contents'}[0]{'args'}[1]{'parent'} =
$result_trees{'good_comment'}{'contents'}[0];
+$result_trees{'good_comment'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'good_comment'}{'contents'}[0];
$result_trees{'good_comment'}{'contents'}[0]{'parent'} =
$result_trees{'good_comment'};
$result_texts{'good_comment'} = '@multitable @columnfractions 0.4 .6 5. @c
comment
Index: t/results/columnfractions/good_space_comment.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/columnfractions/good_space_comment.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/columnfractions/good_space_comment.pl 25 Sep 2010 14:33:39
-0000 1.3
+++ t/results/columnfractions/good_space_comment.pl 25 Sep 2010 16:01:07
-0000 1.4
@@ -34,8 +34,14 @@
}
],
'cmdname' => 'multitable',
+ 'contents' => [
+ {
'contents' => [],
'parent' => {},
+ 'type' => 'before_item'
+ }
+ ],
+ 'parent' => {},
'special' => {
'max_columns' => 2
}
@@ -47,6 +53,7 @@
$result_trees{'good_space_comment'}{'contents'}[0]{'args'}[0]{'parent'} =
$result_trees{'good_space_comment'}{'contents'}[0];
$result_trees{'good_space_comment'}{'contents'}[0]{'args'}[1]{'args'}[0]{'parent'}
= $result_trees{'good_space_comment'}{'contents'}[0]{'args'}[1];
$result_trees{'good_space_comment'}{'contents'}[0]{'args'}[1]{'parent'} =
$result_trees{'good_space_comment'}{'contents'}[0];
+$result_trees{'good_space_comment'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'good_space_comment'}{'contents'}[0];
$result_trees{'good_space_comment'}{'contents'}[0]{'parent'} =
$result_trees{'good_space_comment'};
$result_texts{'good_space_comment'} = '@multitable @columnfractions 0 1 @c
space comment
Index: t/results/columnfractions/not_fraction.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/columnfractions/not_fraction.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/columnfractions/not_fraction.pl 25 Sep 2010 14:33:39 -0000
1.3
+++ t/results/columnfractions/not_fraction.pl 25 Sep 2010 16:01:07 -0000
1.4
@@ -10,8 +10,14 @@
}
],
'cmdname' => 'multitable',
+ 'contents' => [
+ {
'contents' => [],
'parent' => {},
+ 'type' => 'before_item'
+ }
+ ],
+ 'parent' => {},
'special' => {
'max_columns' => 0
}
@@ -19,6 +25,7 @@
]
};
$result_trees{'not_fraction'}{'contents'}[0]{'args'}[0]{'parent'} =
$result_trees{'not_fraction'}{'contents'}[0];
+$result_trees{'not_fraction'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'not_fraction'}{'contents'}[0];
$result_trees{'not_fraction'}{'contents'}[0]{'parent'} =
$result_trees{'not_fraction'};
$result_texts{'not_fraction'} = '@multitable @columnfractions
Index: t/results/columnfractions/wrong_command.pl
===================================================================
RCS file:
/sources/texinfo/texinfo/tp/t/results/columnfractions/wrong_command.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- t/results/columnfractions/wrong_command.pl 25 Sep 2010 14:33:39 -0000
1.3
+++ t/results/columnfractions/wrong_command.pl 25 Sep 2010 16:01:07 -0000
1.4
@@ -32,8 +32,14 @@
}
],
'cmdname' => 'multitable',
+ 'contents' => [
+ {
'contents' => [],
'parent' => {},
+ 'type' => 'before_item'
+ }
+ ],
+ 'parent' => {},
'special' => {
'max_columns' => 0
}
@@ -45,6 +51,7 @@
$result_trees{'wrong_command'}{'contents'}[0]{'args'}[1]{'args'}[0]{'parent'}
= $result_trees{'wrong_command'}{'contents'}[0]{'args'}[1];
$result_trees{'wrong_command'}{'contents'}[0]{'args'}[1]{'parent'} =
$result_trees{'wrong_command'}{'contents'}[0];
$result_trees{'wrong_command'}{'contents'}[0]{'args'}[2]{'parent'} =
$result_trees{'wrong_command'}{'contents'}[0];
+$result_trees{'wrong_command'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'wrong_command'}{'contents'}[0];
$result_trees{'wrong_command'}{'contents'}[0]{'parent'} =
$result_trees{'wrong_command'};
$result_texts{'wrong_command'} = '@multitable @columnfractions @b{3.4}