[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_end_line), tp/Texin
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_end_line), tp/Texinfo/Convert/Texinfo.pm (convert), tp/Texinfo/Convert/TexinfoXML.pm (%ignored_types): Keep @include of included files in tree, with type set to 'replaced'. Ignore 'replaced' type in converters that expand all @-commands, in the default case. If Texinfo.pm convert() has a defined second argument given, expand replaced types. Used in the parser to have @include replaced by its content, with replaced type set shown in error messages. |
Date: |
Sun, 15 Aug 2021 14:21:33 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new 4a3c50c * tp/Texinfo/ParserNonXS.pm (_end_line),
tp/Texinfo/Convert/Texinfo.pm (convert), tp/Texinfo/Convert/TexinfoXML.pm
(%ignored_types): Keep @include of included files in tree, with type set to
'replaced'. Ignore 'replaced' type in converters that expand all @-commands,
in the default case. If Texinfo.pm convert() has a defined second argument
given, expand replaced types. Used in the parser to have @include replaced by
its content, with replaced type set shown in error [...]
4a3c50c is described below
commit 4a3c50c619fda73e6c1e4a93d4a4c24571841a64
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Aug 15 20:21:16 2021 +0200
* tp/Texinfo/ParserNonXS.pm (_end_line),
tp/Texinfo/Convert/Texinfo.pm (convert),
tp/Texinfo/Convert/TexinfoXML.pm (%ignored_types):
Keep @include of included files in tree, with type
set to 'replaced'. Ignore 'replaced' type in converters
that expand all @-commands, in the default case. If
Texinfo.pm convert() has a defined second argument given,
expand replaced types. Used in the parser to have
@include replaced by its content, with replaced type set
shown in error messages.
---
ChangeLog | 13 +++++++++++++
tp/TODO | 12 ++++++++++--
tp/Texinfo/Convert/Texinfo.pm | 25 +++++++++++++++++--------
tp/Texinfo/Convert/TexinfoXML.pm | 2 ++
tp/Texinfo/ParserNonXS.pm | 21 ++++++++++++---------
5 files changed, 54 insertions(+), 19 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 5ff67fa..0e564e2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
2021-08-15 Patrice Dumas <pertusus@free.fr>
+ * tp/Texinfo/ParserNonXS.pm (_end_line),
+ tp/Texinfo/Convert/Texinfo.pm (convert),
+ tp/Texinfo/Convert/TexinfoXML.pm (%ignored_types):
+ Keep @include of included files in tree, with type
+ set to 'replaced'. Ignore 'replaced' type in converters
+ that expand all @-commands, in the default case. If
+ Texinfo.pm convert() has a defined second argument given,
+ expand replaced types. Used in the parser to have
+ @include replaced by its content, with replaced type set
+ shown in error messages.
+
+2021-08-15 Patrice Dumas <pertusus@free.fr>
+
* tp/Texinfo/ParserNonXS.pm (_parse_line_command_args):
fix setchapternewpage argument.
Changes in one debug message, reindent some code.
diff --git a/tp/TODO b/tp/TODO
index 5649b50..154b75a 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -29,6 +29,13 @@ nytprofhtml --open
# firefox nytprof/index.html
+Documentation of tree in ParserNonXS.pm
+=======================================
+
+replaced, elided, elided_block types.
+'extra'->'file' in replaced @include.
+
+
Delayed bugs
============
@@ -152,8 +159,9 @@ bit to update.
Add some elements of texinfo that are not of interest in the
tree, like beginning and end of included file, @ protecting
end of line in @def*, begin and end of user defined macro
-or value expansion. Maybe call the key for these elements
-'sourcemark'?
+or value expansion. For @include @-commands, which are kept,
+the type is set to 'replaced', it could be possible to do the
+same.
In a similar way, keep the information about aliases in the tree?
And about @setfilename in included files which is for now completly
diff --git a/tp/Texinfo/Convert/Texinfo.pm b/tp/Texinfo/Convert/Texinfo.pm
index 3683b56..43c54ca 100644
--- a/tp/Texinfo/Convert/Texinfo.pm
+++ b/tp/Texinfo/Convert/Texinfo.pm
@@ -57,18 +57,25 @@ for my $a (@ignored_types) {
# Following subroutines deal with transforming a texinfo tree into texinfo
# text. Should give the text that was used parsed, except for a few cases.
+# the second arguments, if defined triggers replaced
+# tree item to be shown, in the default case they are
+# not shown.
# expand a tree to the corresponding texinfo.
-sub convert
+sub convert($;$);
+sub convert($;$)
{
my $root = shift;
+ my $expand_replaced = shift;
die "convert: root undef\n" if (!defined($root));
die "convert: bad root type (".ref($root).") $root\n"
if (ref($root) ne 'HASH');
my $result = '';
- return '' if ($root->{'type'} and $ignored_types{$root->{'type'}});
-
+ return '' if ($root->{'type'}
+ and ($ignored_types{$root->{'type'}}
+ or ($root->{'type'} eq 'replaced'
+ and not $expand_replaced)));
if (defined($root->{'text'})) {
$result .= $root->{'text'};
} else {
@@ -76,7 +83,7 @@ sub convert
or ($root->{'type'} and ($root->{'type'} eq 'def_line'
or $root->{'type'} eq 'menu_entry'
or $root->{'type'} eq 'menu_comment'))) {
- $result .= _expand_cmd_args_to_texi($root);
+ $result .= _expand_cmd_args_to_texi($root, $expand_replaced);
}
if ($root->{'type'}
and ($root->{'type'} eq 'bracketed'
@@ -89,14 +96,15 @@ sub convert
}
if (defined($root->{'contents'})) {
foreach my $child (@{$root->{'contents'}}) {
- $result .= convert($child);
+ $result .= convert($child, $expand_replaced);
}
}
if ($root->{'extra'} and $root->{'extra'}->{'spaces_after_argument'}) {
$result .= $root->{'extra'}->{'spaces_after_argument'};
}
if ($root->{'extra'} and $root->{'extra'}->{'comment_at_end'}) {
- $result .= convert($root->{'extra'}->{'comment_at_end'});
+ $result .= convert($root->{'extra'}->{'comment_at_end'},
+ $expand_replaced);
}
$result .= '}' if ($root->{'type'}
and ($root->{'type'} eq 'bracketed'
@@ -128,8 +136,9 @@ sub node_extra_to_texi($)
# expand a command argument as texinfo.
-sub _expand_cmd_args_to_texi {
+sub _expand_cmd_args_to_texi($;$) {
my $cmd = shift;
+ my $expand_replaced = shift;
my $cmdname = $cmd->{'cmdname'};
$cmdname = '' if (!$cmd->{'cmdname'});
@@ -149,7 +158,7 @@ sub _expand_cmd_args_to_texi {
$result .= $cmd->{'extra'}->{'spaces_before_argument'}
if $cmd->{'extra'} and $cmd->{'extra'}->{'spaces_before_argument'};
foreach my $arg (@{$cmd->{'args'}}) {
- $result .= convert($arg);
+ $result .= convert($arg, $expand_replaced);
}
# for misc_commands with type special
} elsif (($cmd->{'extra'} or $cmdname eq 'macro' or $cmdname eq 'rmacro')
diff --git a/tp/Texinfo/Convert/TexinfoXML.pm b/tp/Texinfo/Convert/TexinfoXML.pm
index 89e27d0..ec40ef5 100644
--- a/tp/Texinfo/Convert/TexinfoXML.pm
+++ b/tp/Texinfo/Convert/TexinfoXML.pm
@@ -388,6 +388,8 @@ foreach my $type (
# those are put as spaces in the corresponding @-command
'empty_spaces_after_command',
'empty_spaces_before_argument',
+ # @-commands replaced in the tree
+ 'replaced',
) {
$ignored_types{$type} = 1;
}
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 27061b1..e6f679d 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2477,8 +2477,6 @@ sub _end_line($$$)
my $current_old = $current;
- my $included_file = 0;
-
# a line consisting only of spaces.
if ($current->{'contents'} and @{$current->{'contents'}}
and $current->{'contents'}->[-1]->{'type'}
@@ -2986,7 +2984,6 @@ sub _end_line($$$)
if (defined($file)) {
my $filehandle = do { local *FH };
if (_open_in ($self, $filehandle, $file)) {
- $included_file = 1;
print STDERR "Included $file($filehandle)\n" if
($self->{'DEBUG'});
my ($directories, $suffix);
($file, $directories, $suffix) = fileparse($file);
@@ -2995,6 +2992,10 @@ sub _end_line($$$)
'line_nr' => 0,
'pending' => [],
'fh' => $filehandle };
+ $current->{'extra'}->{'file'} = $file;
+ # we set thetype to replaced to tell converters not to
+ # expand the @-command
+ $current->{'type'} = 'replaced';
} else {
$self->_command_error($current, $line_nr,
__("\@%s: could not open %s: %s"),
@@ -3045,8 +3046,11 @@ sub _end_line($$$)
}
}
if ($superfluous_arg) {
+ # note that the argument to expand replaced @-commands is
+ # set, such that @include that are removed from the tree
+ # with type set to replaced are still shown in error messages.
my $texi_line
- = Texinfo::Convert::Texinfo::convert($current->{'args'}->[0]);
+ = Texinfo::Convert::Texinfo::convert($current->{'args'}->[0], 1);
$texi_line =~ s/^\s*//;
$texi_line =~ s/\s*$//;
@@ -3128,11 +3132,10 @@ sub _end_line($$$)
$current = _begin_preformatted($self, $current)
if ($close_preformatted_commands{$command});
}
- # if a file was included, remove completly the include file command.
- # Also ignore @setfilename in included file, as said in the manual.
- if ($included_file or ($command eq 'setfilename'
- and scalar(@{$self->{'input'}}) > 1)) {
- # TODO keep the information with sourcemark
+ # Ignore @setfilename in included file, as said in the manual.
+ if ($command eq 'setfilename'
+ and scalar(@{$self->{'input'}}) > 1) {
+ # TODO keep the information
pop @{$current->{'contents'}};
} elsif ($command eq 'setfilename'
and ($self->{'current_node'} or $self->{'current_section'})) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_end_line), tp/Texinfo/Convert/Texinfo.pm (convert), tp/Texinfo/Convert/TexinfoXML.pm (%ignored_types): Keep @include of included files in tree, with type set to 'replaced'. Ignore 'replaced' type in converters that expand all @-commands, in the default case. If Texinfo.pm convert() has a defined second argument given, expand replaced types. Used in the parser to have @include replaced by its content, with replaced type set shown in error messages.,
Patrice Dumas <=