[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_def): use cod
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_def): use code more similar to XS parser to set the def_role for the rest or arguments. |
Date: |
Mon, 27 Mar 2023 16:39:19 -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 2a88914bc8 * tp/Texinfo/ParserNonXS.pm (_parse_def): use code more
similar to XS parser to set the def_role for the rest or arguments.
2a88914bc8 is described below
commit 2a88914bc8620ccb781beb0acccff7118785d1c0
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Mar 27 22:39:13 2023 +0200
* tp/Texinfo/ParserNonXS.pm (_parse_def): use code more similar to XS
parser to set the def_role for the rest or arguments.
* tp/Texinfo/XS/parsetexi/def.c (parse_def): rename next_type as
set_type_not_arg.
---
ChangeLog | 8 ++++++++
tp/Texinfo/ParserNonXS.pm | 41 ++++++++++++++++++++---------------------
tp/Texinfo/XS/parsetexi/def.c | 16 +++++++++-------
3 files changed, 37 insertions(+), 28 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 81963512ce..1435323e93 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-03-27 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (_parse_def): use code more similar to XS
+ parser to set the def_role for the rest or arguments.
+
+ * tp/Texinfo/XS/parsetexi/def.c (parse_def): rename next_type as
+ set_type_not_arg.
+
2023-03-27 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_parse_def),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 572a8cf715..0bac874d4e 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2904,6 +2904,7 @@ sub _split_delimiters
$current_position, length($1));
} elsif ($text =~ s/^([$chars])//) {
push @elements, {'text' => $1, 'type' => 'delimiter',
+ 'extra' => {'def_role' => 'delimiter'},
'parent' => $root->{'parent'}};
$current_position = Texinfo::Common::relocate_source_marks(
$remaining_source_marks, $elements[-1],
@@ -3115,6 +3116,7 @@ sub _parse_def($$$$)
$contents_idx++;
}
if ($contents_idx < scalar(@{$current->{'contents'}})
+ # should only happen if there is no argument at all for the linemacro
and $i < scalar(@args)) {
my $contents_nr = scalar(@{$current->{'contents'}}) - $contents_idx;
if ($contents_nr == 1) {
@@ -3146,33 +3148,31 @@ sub _parse_def($$$$)
scalar(@{$current->{'contents'}}) -
$contents_idx));
push @{$current->{'contents'}}, @args_results;
- # Create the part of the parsed def line array for any arguments.
+ # set def_role for the rest of arguments.
+ my $set_type_not_arg = 1;
+ # For some commands, alternate between "arg" and "typearg".
+ # In that case $set_type_not_arg is both used to set to argtype and
+ # to switch sign to switch between arg and argtype
+ $set_type_not_arg = -1 if ($arg_type and $arg_type eq 'argtype');
+
+ my $type = $set_type_not_arg;
+
foreach my $content (@args_results) {
if ($content->{'type'} and $content->{'type'} eq 'spaces') {
- $content->{'extra'} = {'def_role' => 'spaces'};
} elsif ($content->{'type'} and $content->{'type'} eq 'delimiter') {
- $content->{'extra'} = {'def_role' => 'delimiter'};
- } else {
+ $type = $set_type_not_arg;
+ } elsif ($content->{'cmdname'} and $content->{'cmdname'} ne 'code') {
$content->{'extra'} = {} if (!$content->{'extra'});
$content->{'extra'}->{'def_role'} = 'arg';
- }
- }
-
- # If a command like @deftypefn, mark the type arguments
- if ($arg_type and $arg_type eq 'argtype') {
- my $next_is_type = 1;
- foreach my $arg(@args_results) {
- if ($arg->{'extra'}->{'def_role'} eq 'spaces') {
- } elsif ($arg->{'extra'}->{'def_role'} eq 'delimiter') {
- $next_is_type = 1;
- } elsif ($arg->{'cmdname'} and $arg->{'cmdname'} ne 'code') {
- $next_is_type = 1;
- } elsif ($next_is_type) {
- $arg->{'extra'}->{'def_role'} = 'typearg';
- $next_is_type = 0;
+ $type = $set_type_not_arg;
+ } else {
+ $content->{'extra'} = {} if (!$content->{'extra'});
+ if ($type == 1) {
+ $content->{'extra'}->{'def_role'} = 'arg';
} else {
- $next_is_type = 1;
+ $content->{'extra'}->{'def_role'} = 'typearg';
}
+ $type = $type * $set_type_not_arg;
}
}
@@ -6827,7 +6827,6 @@ sub _process_remaining_on_line($$$$)
} elsif ($arguments_container) {
# linemacro defined command call
push @{$current->{'contents'}}, $arguments_container;
- # FIXME needed? Correct?
$arguments_container->{'parent'} = $current;
# FIXME needed? Correct?
$arguments_container->{'source_info'} = $source_info;
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index 1ca3035b9c..e5fa9c73d7 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -327,7 +327,7 @@ DEF_ARG **
parse_def (enum command_id command, ELEMENT *current)
{
int contents_idx = 0;
- int type, next_type;
+ int type, set_type_not_arg;
int i, i_def;
int arg_types_nr;
ELEMENT *e, *e1;
@@ -501,13 +501,15 @@ parse_def (enum command_id command, ELEMENT *current)
/* For some commands, alternate between "arg" and "typearg". This matters for
the DocBook output. */
+ /* In that case set_type_not_arg is both used to set to argtype and
+ to switch sign to switch between arg and argtype */
if (command == CM_deftypefn || command == CM_deftypeop
|| command == CM_deftp)
- next_type = -1;
+ set_type_not_arg = -1;
else
- next_type = 1;
+ set_type_not_arg = 1;
- type = next_type;
+ type = set_type_not_arg;
for (i = contents_idx; i < current->contents.number; i++)
{
e = contents_child_by_index (current, i);
@@ -518,18 +520,18 @@ parse_def (enum command_id command, ELEMENT *current)
}
if (e->type == ET_delimiter)
{
- type = next_type;
+ type = set_type_not_arg;
continue;
}
if (e->cmd && e->cmd != CM_code)
{
add_extra_string_dup (e, "def_role", "arg");
- type = next_type;
+ type = set_type_not_arg;
continue;
}
add_extra_string_dup (e, "def_role",
(type == 1 ? "arg" : "typearg"));
- type *= next_type;
+ type *= set_type_not_arg;
}
return result;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (_parse_def): use code more similar to XS parser to set the def_role for the rest or arguments.,
Patrice Dumas <=