texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_o


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), tp/Texinfo/XS/parsetexi/menus.c (handle_menu): synchronize and improve comments and debug messages. No change in code.
Date: Thu, 02 Mar 2023 07:48:26 -0500

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 4dc341788f * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line), 
tp/Texinfo/XS/parsetexi/menus.c (handle_menu): synchronize and improve comments 
and debug messages.  No change in code.
4dc341788f is described below

commit 4dc341788fcf5b1d0f02635e6f7408abaa82f951
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Mar 2 13:48:14 2023 +0100

    * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
    tp/Texinfo/XS/parsetexi/menus.c (handle_menu): synchronize and improve
    comments and debug messages.  No change in code.
---
 ChangeLog                       |  6 ++++++
 tp/TODO                         | 10 +++++++---
 tp/Texinfo/ParserNonXS.pm       | 25 ++++++++++++++-----------
 tp/Texinfo/XS/parsetexi/menus.c | 26 ++++++++++++++++----------
 4 files changed, 43 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 20b000017d..c6362b7dcf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-03-02  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line),
+       tp/Texinfo/XS/parsetexi/menus.c (handle_menu): synchronize and improve
+       comments and debug messages.  No change in code.
+
 2023-03-01  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_next_text): remove 'fh' at the end of
diff --git a/tp/TODO b/tp/TODO
index 98691f4e7e..44e1eabb43 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -18,6 +18,13 @@ Also inconsistent entries for item and item as item_LINE, 
would be
 better to modify the perl parser to use item_LINE and item like
 the XS parser.
 
+source marks in parse_node_manual
+
+Add source marks for alias. Not easy, as command elements are added in many
+places in the code.
+
+
+
 HTML API
 ========
 
@@ -98,9 +105,6 @@ the context command stack.
  @end defun
 
 
-Add source marks for alias. Not easy, as command elements are added in many
-places in the code.
-
 
 In HTML, some @-commands do not have an element with a class associated, or the
 association is not perfect.  There is @author in @quotation, @-command affected
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index ca468acb24..81819e1ec1 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -5343,10 +5343,11 @@ sub _process_remaining_on_line($$$$)
            and $current->{'contents'}->[-1]->{'type'} eq 
'menu_entry_separator') {
     print STDERR "AFTER menu_entry_separator\n" if ($self->{'DEBUG'});
     my $separator = $current->{'contents'}->[-1]->{'text'};
-    # separator is ::, we concatenate and let the while restart
-    # in order to collect spaces below
+    # Separator is ::.
     if ($separator eq ':' and $line =~ s/^(:)//) {
       $current->{'contents'}->[-1]->{'text'} .= $1;
+      # Whitespace following the :: is subsequently appended to
+      # the separator.
     # a . not followed by a space.  Not a separator.
     } elsif ($separator eq '.' and $line =~ /^\S/) {
       my $popped_element = _pop_element_from_contents($self, $current);
@@ -5358,22 +5359,24 @@ sub _process_remaining_on_line($$$$)
       # of the separator. Right now it is part of the description,
       # since it is catched (in the next while) as one of the case below
       $current->{'contents'}->[-1]->{'text'} .= $1;
-    # now handle the menu part that was closed
+    # :: after a menu entry name => change to a menu entry node
     } elsif ($separator =~ /^::/) {
-      print STDERR "MENU NODE no name $separator\n" if ($self->{'DEBUG'});
-      # it was previously registered as menu_entry_name, it is
-      # changed to node
+      print STDERR "MENU NODE done (change from menu entry name) $separator\n"
+          if ($self->{'DEBUG'});
+      # Change from menu_entry_name (i.e. a label)
+      # to a menu entry node
       $current->{'contents'}->[-2]->{'type'} = 'menu_entry_node';
       $current = _enter_menu_entry_node($self, $current, $source_info);
-    # end of the menu entry name
+    # a :, but not ::, after a menu entry name => end of menu entry name
     } elsif ($separator =~ /^:/) {
-      print STDERR "MENU ENTRY $separator\n" if ($self->{'DEBUG'});
+      print STDERR "MENU ENTRY done $separator\n" if ($self->{'DEBUG'});
       push @{$current->{'contents'}}, { 'type' => 'menu_entry_node',
                                         'parent' => $current };
       $current = $current->{'contents'}->[-1];
-    # anything else is the end of the menu node following a menu_entry_name
+    # anything else corresponds to a separator that does not contain
+    # : and is after a menu node (itself following a menu_entry_name)
     } else {
-      print STDERR "MENU NODE $separator\n" if ($self->{'DEBUG'});
+      print STDERR "MENU NODE done $separator\n" if ($self->{'DEBUG'});
       $current = _enter_menu_entry_node($self, $current, $source_info);
     }
   # Any other @-command.
@@ -6964,7 +6967,7 @@ sub _parse_line_command_args($$$)
     return undef;
   }
 
-  if (@{$arg->{'contents'}} > 1
+  if (scalar(@{$arg->{'contents'}}) > 1
          or (!defined($arg->{'contents'}->[0]->{'text'}))) {
     $self->_line_error(sprintf(__("superfluous argument to \@%s"),
        $command), $source_info);
diff --git a/tp/Texinfo/XS/parsetexi/menus.c b/tp/Texinfo/XS/parsetexi/menus.c
index 120f400fb5..18013175aa 100644
--- a/tp/Texinfo/XS/parsetexi/menus.c
+++ b/tp/Texinfo/XS/parsetexi/menus.c
@@ -74,7 +74,7 @@ register_extra_menu_entry_information (ELEMENT *current)
   return menu_entry_node;
 }
 
-/* Process the destination of the menu entry, and start a menu entry 
+/* Process the destination of the menu entry, and start a menu entry
    description.  */
 ELEMENT *
 enter_menu_entry_node (ELEMENT *current)
@@ -98,7 +98,7 @@ enter_menu_entry_node (ELEMENT *current)
   return current;
 }
 
-/* Called from 'process_remaining_on_line' in parser.c.  Return 1 if we find 
+/* Called from 'process_remaining_on_line' in parser.c.  Return 1 if we find
    menu syntax to process, otherwise return 0. */
 int
 handle_menu (ELEMENT **current_inout, char **line_inout)
@@ -186,8 +186,10 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
       debug ("ABORT MENU STAR");
       last_contents_child(current)->type = ET_NONE;
     }
-  /* After a separator in a menu (which would have been added in
-     handle_separator in separator.c). */
+  /* After a separator in a menu, which would have been added in
+     handle_separator in separator.c:
+       , tab or . after ET_menu_entry_node
+       : after ET_menu_entry_name */
   else if (current->contents.number > 0
            && last_contents_child (current)->type == ET_menu_entry_separator)
     {
@@ -213,7 +215,7 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
           merge_text (current, last_child->text.text, last_child);
           destroy_element (last_child);
         }
-      /* here we collect spaces following separators. */
+      /* here we collect spaces following separators². */
       else if (strchr (whitespace_chars_except_newline, *line))
         {
           int n;
@@ -222,30 +224,34 @@ handle_menu (ELEMENT **current_inout, char **line_inout)
           text_append_n (&last_child->text, line, n);
           line += n;
         }
+      /* :: after a menu entry name => change to a menu entry node */
       else if (!strncmp (separator, "::", 2))
         {
           ELEMENT *entry_name;
 
-          debug ("MENU NODE no entry %s", separator);
+          debug ("MENU NODE done (change from menu entry name) %s", separator);
           entry_name = contents_child_by_index (current, -2);
 
-          /* Change it from ET_menu_entry_name (i.e. the label). */
+          /* Change from menu_entry_name (i.e. a label)
+             to a menu entry node */
           entry_name->type = ET_menu_entry_node;
           current = enter_menu_entry_node (current);
         }
-      /* End of the label.  Begin the element for the destination. */
+      /* a :, but not ::, after a menu entry name => end of menu entry name */
       else if (*separator == ':')
         {
           ELEMENT *entry_node;
 
-          debug ("MENU ENTRY %s", separator);
+          debug ("MENU ENTRY done %s", separator);
           entry_node = new_element (ET_menu_entry_node);
           add_to_element_contents (current, entry_node);
           current = entry_node;
         }
       else
+      /* anything else corresponds to a separator that does not contain
+         : and is after a menu node (itself following a menu_entry_name) */
         {
-          debug ("MENU NODE");
+          debug ("MENU NODE done %s", separator);
           current = enter_menu_entry_node (current);
         }
     }



reply via email to

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