[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[8176] do not set block_command_line_contents
From: |
gavinsmith0123 |
Subject: |
[8176] do not set block_command_line_contents |
Date: |
Sat, 15 Sep 2018 17:08:13 -0400 (EDT) |
Revision: 8176
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8176
Author: gavin
Date: 2018-09-15 17:08:13 -0400 (Sat, 15 Sep 2018)
Log Message:
-----------
do not set block_command_line_contents
Modified Paths:
--------------
trunk/ChangeLog
trunk/tp/Texinfo/Parser.pm
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2018-09-15 18:37:25 UTC (rev 8175)
+++ trunk/ChangeLog 2018-09-15 21:08:13 UTC (rev 8176)
@@ -1,5 +1,24 @@
2018-09-15 Gavin Smith <address@hidden>
+ * tp/Texinfo/Parser.pm (_remove_empty_content_arguments):
+ Remove function.
+ (_register_command_arg): Remove function.
+ (module documentation section): Remove mention of
+ 'block_command_line_contents'.
+ (_end_line): Do not set or access 'block_command_line_contents'
+ extra value.
+
+ This is intended to simplify the parse tree. Reducing
+ duplication of information makes it easier to track what data
+ leads to output at later stages of processing. It reduces
+ memory use and may increase speed. It makes it easier to
+ inspect data structures that are "dumped" to a text stream. It
+ is also easier to handle memory allocation in a rewrite in
+ another programming language if the data structures are less
+ cyclic.
+
+2018-09-15 Gavin Smith <address@hidden>
+
* tp/t/91morecoverage.t: New file.
* tp/t/91morecoverage.t (texi_formatting, formatting_fr):
New tests.
Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm 2018-09-15 18:37:25 UTC (rev 8175)
+++ trunk/tp/Texinfo/Parser.pm 2018-09-15 21:08:13 UTC (rev 8176)
@@ -2562,25 +2562,6 @@
$current->{'extra'}->{'index_entry'} = $index_entry;
}
-# This is always called at command closing.
-sub _remove_empty_content_arguments($)
-{
- my $current = shift;
- my $type;
- if ($current->{'extra'}
- and $current->{'extra'}->{'block_command_line_contents'}) {
- $type = 'block_command_line_contents';
- }
- if ($type) {
- while (@{$current->{'extra'}->{$type}}
- and not defined($current->{'extra'}->{$type}->[-1])) {
- pop @{$current->{'extra'}->{$type}};
- }
- delete $current->{'extra'}->{$type} if
(address@hidden>{'extra'}->{$type}});
- delete $current->{'extra'} if (!keys(%{$current->{'extra'}}));
- }
-}
-
# close constructs and do stuff at end of line (or end of the document)
sub _end_line($$$);
sub _end_line($$$)
@@ -2871,10 +2852,8 @@
}
$multitable->{'extra'}->{'prototypes'} = address@hidden;
_isolate_last_space($self, $current);
-
} else {
_isolate_last_space($self, $current);
- _register_command_arg($self, $current, 'block_command_line_contents');
}
# @float args
if ($current->{'parent'}->{'cmdname'}
@@ -2909,21 +2888,20 @@
unshift @{$current->{'contents'}}, $empty_text;
delete $current->{'args'};
}
- # Additionally, remove empty arguments as far as possible
- _remove_empty_content_arguments($current);
if ($current->{'cmdname'}
and $block_item_commands{$current->{'cmdname'}}) {
if ($current->{'cmdname'} eq 'enumerate') {
my $spec = 1;
- if ($current->{'extra'}->{'block_command_line_contents'}
- and
defined($current->{'extra'}->{'block_command_line_contents'}->[0])) {
- if
(scalar(@{$current->{'extra'}->{'block_command_line_contents'}->[0]}) > 1) {
+ if ($current->{'args'} and $current->{'args'}->[0]
+ and $current->{'args'}->[0]->{'contents'}
+ and @{$current->{'args'}->[0]->{'contents'}}) {
+ if (scalar(@{$current->{'args'}->[0]->{'contents'}}) > 1) {
$self->_command_error($current, $line_nr,
__("superfluous argument to address@hidden"),
$current->{'cmdname'});
}
- my $arg =
$current->{'extra'}->{'block_command_line_contents'}->[0]->[0];
+ my $arg = $current->{'args'}->[0]->{'contents'}->[0];
if (!defined($arg->{'text'}) or $arg->{'text'} !~
/^(([[:digit:]]+)|([[:alpha:]]+))$/) {
$self->_command_error($current, $line_nr,
__("bad argument to address@hidden"),
@@ -2981,32 +2959,26 @@
$current->{'extra'}->{'command_as_argument'}->{'cmdname'},
$current->{'cmdname'});
delete $current->{'extra'}->{'command_as_argument'};
- delete $current->{'extra'}->{'block_command_line_contents'};
}
- if (!$current->{'extra'}->{'block_command_line_contents'}
- and $current->{'cmdname'} eq 'itemize') {
+ if ($current->{'cmdname'} eq 'itemize'
+ and (!$current->{'args'}
+ or !$current->{'args'}->[0]
+ or !$current->{'args'}->[0]->{'contents'}
+ or address@hidden>{'args'}->[0]->{'contents'}})) {
my $inserted = { 'cmdname' => 'bullet',
'contents' => [],
'type' => 'command_as_argument_inserted',
'parent' => $current };
unshift @{$current->{'args'}}, $inserted;
- $current->{'extra'}->{'block_command_line_contents'} = [
- [ $inserted ]
- ];
- $current->{'extra'}->{'command_as_argument'} =
- $current->{'extra'}->{'block_command_line_contents'}->[0]->[0];
+ $current->{'extra'}->{'command_as_argument'} = $inserted;
} elsif ($item_line_commands{$current->{'cmdname'}} and
- ! $current->{'extra'}->{'command_as_argument'}) {
+ !$current->{'extra'}->{'command_as_argument'}) {
my $inserted = { 'cmdname' => 'asis',
'contents' => [],
'type' => 'command_as_argument_inserted',
'parent' => $current };
unshift @{$current->{'args'}}, $inserted;
- $current->{'extra'}->{'block_command_line_contents'} = [
- [ $inserted ]
- ];
- $current->{'extra'}->{'command_as_argument'} =
- $current->{'extra'}->{'block_command_line_contents'}->[0]->[0];
+ $current->{'extra'}->{'command_as_argument'} = $inserted;
}
push @{$current->{'contents'}}, { 'type' => 'before_item',
'contents' => [], 'parent', $current };
@@ -3534,19 +3506,6 @@
return $current;
}
-sub _register_command_arg($$$)
-{
- my ($self, $current, $type) = @_;
-
- my @contents = @{$current->{'contents'}};
- _trim_spaces_comment_from_content(address@hidden);
- if (scalar(@contents)) {
- push @{$current->{'parent'}->{'extra'}->{$type}}, address@hidden;
- } else {
- push @{$current->{'parent'}->{'extra'}->{$type}}, undef;
- }
-}
-
sub _command_with_command_as_argument($)
{
my $current = shift;
@@ -5065,8 +5024,6 @@
# @inline* always have end spaces considered as normal text
_isolate_last_space($self, $current)
unless ($inline_commands{$current->{'parent'}->{'cmdname'}});
- # Remove empty arguments, as far as possible
- _remove_empty_content_arguments($current);
}
my $closed_command = $current->{'parent'}->{'cmdname'};
print STDERR "CLOSING(brace)
address@hidden>{'parent'}->{'cmdname'}\n"
@@ -5296,16 +5253,7 @@
} elsif ($separator eq ','
and $current->{'parent'}->{'remaining_args'}) {
_abort_empty_line ($self, $current);
- if ($brace_commands{$current->{'parent'}->{'cmdname'}}
- and ($brace_commands{$current->{'parent'}->{'cmdname'}} > 1
- or $simple_text_commands{$current->{'parent'}->{'cmdname'}}))
{
- _isolate_last_space($self, $current);
- } else {
- _isolate_last_space($self, $current);
- if (exists $block_commands{$current->{'parent'}->{'cmdname'}}) {
- _register_command_arg($self, $current,
'block_command_line_contents');
- }
- }
+ _isolate_last_space($self, $current);
my $type = $current->{'type'};
$current = $current->{'parent'};
if ($inline_commands{$current->{'cmdname'}}) {
@@ -6857,12 +6805,6 @@
=over
-=item block_command_line_contents
-
-An array associated with block @-commands. Each of the elements of the
-array is either undef, if there is no argument at that place,
-or an array reference holding the argument contents.
-
=item misc_content
The contents of an @-command taking regular Texinfo code as
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [8176] do not set block_command_line_contents,
gavinsmith0123 <=