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 (_next_bracketed_or_w


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/ParserNonXS.pm (_next_bracketed_or_word_agg), tp/Texinfo/XS/parsetexi/def.c (next_bracketed_or_word_agg): to be consistent with Texinfo TeX, only spaces delimitates arguments, matching braces (bracketed_arg) do not automatically start a new argument.
Date: Mon, 27 Mar 2023 17:08:57 -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 cb3cf36a21 * tp/Texinfo/ParserNonXS.pm (_next_bracketed_or_word_agg), 
tp/Texinfo/XS/parsetexi/def.c (next_bracketed_or_word_agg): to be consistent 
with Texinfo TeX, only spaces delimitates arguments, matching braces 
(bracketed_arg) do not automatically start a new argument.
cb3cf36a21 is described below

commit cb3cf36a216f88d3eb690acc16d1e9297a7a8a57
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Mon Mar 27 23:08:52 2023 +0200

    * tp/Texinfo/ParserNonXS.pm (_next_bracketed_or_word_agg),
    tp/Texinfo/XS/parsetexi/def.c (next_bracketed_or_word_agg): to be
    consistent with Texinfo TeX, only spaces delimitates arguments,
    matching braces (bracketed_arg) do not automatically start a new
    argument.
    
    * tp/t/65linemacro.t: change braces_after_text to use @defline and
    @defblock to have results easier to interpret.
---
 ChangeLog                                   |  11 +
 tp/Texinfo/ParserNonXS.pm                   |  13 +-
 tp/Texinfo/XS/parsetexi/def.c               |  19 +-
 tp/t/65linemacro.t                          |   6 +-
 tp/t/results/linemacro/braces_after_text.pl | 336 ++++++++++++++++++----------
 tp/t/results/linemacro/spaces_in_call.pl    | 140 ++++++------
 6 files changed, 311 insertions(+), 214 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 71384b022d..ffd9dbec83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2023-03-27  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/ParserNonXS.pm (_next_bracketed_or_word_agg),
+       tp/Texinfo/XS/parsetexi/def.c (next_bracketed_or_word_agg): to be
+       consistent with Texinfo TeX, only spaces delimitates arguments,
+       matching braces (bracketed_arg) do not automatically start a new
+       argument.
+
+       * tp/t/65linemacro.t: change braces_after_text to use @defline and
+       @defblock to have results easier to interpret.
+
 2023-03-27  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_handle_macro)
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index eec9a29f8b..8acc0d05d1 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -2996,18 +2996,11 @@ sub _next_bracketed_or_word_agg($$)
       last if ($num > 0);
 
       $$index_ref++;
-      next;
-    } elsif ($element->{'type'}
-             and ($element->{'type'} eq 'bracketed_arg'
-                  or $element->{'type'} eq 'bracketed_inserted')) {
-      last if ($num > 0);
-
+    } else {
+      # element is a text, a command element or a bracketed argument
       $$index_ref++;
-      return $element;
+      $num++;
     }
-    # element is a text or command element
-    $$index_ref++;
-    $num++;
   }
 
   return undef if ($num == 0);
diff --git a/tp/Texinfo/XS/parsetexi/def.c b/tp/Texinfo/XS/parsetexi/def.c
index e5fa9c73d7..7c6ff85a42 100644
--- a/tp/Texinfo/XS/parsetexi/def.c
+++ b/tp/Texinfo/XS/parsetexi/def.c
@@ -93,26 +93,19 @@ next_bracketed_or_word_agg (ELEMENT *current, int *i)
           else
             {
               (*i)++;
-              continue;
             }
         }
-      if (e->type == ET_bracketed_arg
-          || e->type == ET_bracketed_inserted)
+      else
         {
-          if (num > 0)
-            break;
-          else
-            {
-              (*i)++;
-              return e;
-            }
+         /* e is a text or command element or bracketed argument */
+          (*i)++;
+          num++;
         }
-      /* e is a text or command element */
-      (*i)++;
-      num++;
     }
+
   if (num == 0)
     return 0;
+
   if (num == 1)
     return current->contents.list[*i - 1];
 
diff --git a/tp/t/65linemacro.t b/tp/t/65linemacro.t
index ba1f6c9f19..a9655e4665 100644
--- a/tp/t/65linemacro.t
+++ b/tp/t/65linemacro.t
@@ -64,13 +64,14 @@ Body.
 @end defblock
 '],
 # arguments should be 'text{in paren}'  rest{in paren}'  ''
-# FIXME This is not currently the result, but result is incorrect for @def*
 ['braces_after_text',
 '@linemacro mymacro {a, b, c}
-expand \a\ \b\ \c\
+@defline \a\ \b\ \c\
 @end linemacro
 
+@defblock
 @mymacro text{in paren} rest{in paren} {}
+@end defblock
 '],
 # continuation with the first call, with @@ there is no continuation
 ['protected_spaces_on_line',
@@ -113,7 +114,6 @@ something
 @mylinecommand @abc {d} @ringaccent b rest
 '],
 # first argument should be {a b}{c d}{rest}
-# FIXME not currently ok
 ['spaces_in_call',
 '@linemacro mylinecommand {first, second, rest}
 @defblock
diff --git a/tp/t/results/linemacro/braces_after_text.pl 
b/tp/t/results/linemacro/braces_after_text.pl
index 0c942e1f0e..45638b647d 100644
--- a/tp/t/results/linemacro/braces_after_text.pl
+++ b/tp/t/results/linemacro/braces_after_text.pl
@@ -31,7 +31,7 @@ $result_trees{'braces_after_text'} = {
           'cmdname' => 'linemacro',
           'contents' => [
             {
-              'text' => 'expand \\a\\ \\b\\ \\c\\
+              'text' => '@defline \\a\\ \\b\\ \\c\\
 ',
               'type' => 'raw'
             },
@@ -84,100 +84,240 @@ $result_trees{'braces_after_text'} = {
           'type' => 'empty_line'
         },
         {
-          'source_marks' => [
+          'args' => [
             {
-              'counter' => 1,
-              'element' => {
-                'args' => [
-                  {
-                    'contents' => [
-                      {
-                        'text' => 'text'
-                      },
-                      {
-                        'contents' => [
-                          {
-                            'text' => 'in paren'
-                          }
-                        ],
-                        'type' => 'bracketed_arg'
-                      },
-                      {
-                        'extra' => {
-                          'def_role' => 'spaces'
-                        },
-                        'text' => ' ',
-                        'type' => 'spaces'
-                      },
-                      {
-                        'contents' => [
-                          {
-                            'text' => 'rest'
-                          },
+              'info' => {
+                'spaces_after_argument' => {
+                  'text' => '
+'
+                }
+              },
+              'type' => 'block_line_arg'
+            }
+          ],
+          'cmdname' => 'defblock',
+          'contents' => [
+            {
+              'contents' => [
+                {
+                  'source_marks' => [
+                    {
+                      'counter' => 1,
+                      'element' => {
+                        'args' => [
                           {
                             'contents' => [
                               {
-                                'text' => 'in paren'
+                                'contents' => [
+                                  {
+                                    'text' => 'text'
+                                  },
+                                  {
+                                    'contents' => [
+                                      {
+                                        'text' => 'in paren'
+                                      }
+                                    ],
+                                    'type' => 'bracketed_arg'
+                                  }
+                                ],
+                                'type' => 'def_aggregate'
+                              },
+                              {
+                                'extra' => {
+                                  'def_role' => 'spaces'
+                                },
+                                'text' => ' ',
+                                'type' => 'spaces'
+                              },
+                              {
+                                'contents' => [
+                                  {
+                                    'text' => 'rest'
+                                  },
+                                  {
+                                    'contents' => [
+                                      {
+                                        'text' => 'in paren'
+                                      }
+                                    ],
+                                    'type' => 'bracketed_arg'
+                                  }
+                                ],
+                                'type' => 'def_aggregate'
+                              },
+                              {
+                                'extra' => {
+                                  'def_role' => 'spaces'
+                                },
+                                'text' => ' ',
+                                'type' => 'spaces'
+                              },
+                              {
+                                'type' => 'bracketed_arg'
                               }
                             ],
-                            'type' => 'bracketed_arg'
-                          },
-                          {
-                            'extra' => {
-                              'def_role' => 'spaces'
+                            'info' => {
+                              'spaces_after_argument' => {
+                                'text' => '
+'
+                              }
                             },
-                            'text' => ' ',
-                            'type' => 'spaces'
-                          },
-                          {
-                            'type' => 'bracketed_arg'
+                            'type' => 'line_arg'
                           }
                         ],
-                        'type' => 'def_aggregate'
-                      }
-                    ],
-                    'info' => {
-                      'spaces_after_argument' => {
-                        'text' => '
-'
-                      }
+                        'extra' => {
+                          'name' => 'mymacro'
+                        },
+                        'info' => {
+                          'spaces_before_argument' => {
+                            'text' => ' '
+                          }
+                        },
+                        'type' => 'linemacro_call'
+                      },
+                      'sourcemark_type' => 'linemacro_expansion',
+                      'status' => 'start'
+                    }
+                  ],
+                  'text' => '',
+                  'type' => 'empty_line'
+                }
+              ],
+              'type' => 'def_item'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'contents' => [
+                        {
+                          'text' => 'text'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'in paren'
+                            }
+                          ],
+                          'source_info' => {
+                            'file_name' => '',
+                            'line_nr' => 6,
+                            'macro' => 'mymacro'
+                          },
+                          'type' => 'bracketed_arg'
+                        }
+                      ],
+                      'extra' => {
+                        'def_role' => 'category'
+                      },
+                      'type' => 'def_aggregate'
+                    },
+                    {
+                      'extra' => {
+                        'def_role' => 'spaces'
+                      },
+                      'text' => ' ',
+                      'type' => 'spaces'
                     },
-                    'type' => 'line_arg'
-                  }
-                ],
-                'extra' => {
-                  'name' => 'mymacro'
-                },
-                'info' => {
-                  'spaces_before_argument' => {
-                    'text' => ' '
-                  }
-                },
-                'type' => 'linemacro_call'
+                    {
+                      'contents' => [
+                        {
+                          'text' => 'rest'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'in paren'
+                            }
+                          ],
+                          'source_info' => {
+                            'file_name' => '',
+                            'line_nr' => 6,
+                            'macro' => 'mymacro'
+                          },
+                          'type' => 'bracketed_arg'
+                        }
+                      ],
+                      'extra' => {
+                        'def_role' => 'name'
+                      },
+                      'type' => 'def_aggregate'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_after_argument' => {
+                      'text' => ' 
+'
+                    }
+                  },
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'defline',
+              'extra' => {
+                'def_command' => 'defline',
+                'def_index_element' => {},
+                'original_def_cmdname' => 'defline'
+              },
+              'info' => {
+                'spaces_before_argument' => {
+                  'text' => ' '
+                }
+              },
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 6,
+                'macro' => 'mymacro'
               },
-              'sourcemark_type' => 'linemacro_expansion',
-              'status' => 'start'
-            }
-          ],
-          'text' => '',
-          'type' => 'empty_line'
-        },
-        {
-          'contents' => [
-            {
               'source_marks' => [
                 {
                   'counter' => 1,
-                  'position' => 35,
                   'sourcemark_type' => 'linemacro_expansion',
                   'status' => 'end'
                 }
               ],
-              'text' => 'expand text in paren restin paren 
+              'type' => 'def_line'
+            },
+            {
+              'args' => [
+                {
+                  'contents' => [
+                    {
+                      'text' => 'defblock'
+                    }
+                  ],
+                  'info' => {
+                    'spaces_after_argument' => {
+                      'text' => '
 '
+                    }
+                  },
+                  'type' => 'line_arg'
+                }
+              ],
+              'cmdname' => 'end',
+              'extra' => {
+                'text_arg' => 'defblock'
+              },
+              'info' => {
+                'spaces_before_argument' => {
+                  'text' => ' '
+                }
+              },
+              'source_info' => {
+                'file_name' => '',
+                'line_nr' => 7,
+                'macro' => ''
+              }
             }
           ],
-          'type' => 'paragraph'
+          'source_info' => {
+            'file_name' => '',
+            'line_nr' => 5,
+            'macro' => ''
+          }
         }
       ],
       'type' => 'before_node_section'
@@ -185,57 +325,23 @@ $result_trees{'braces_after_text'} = {
   ],
   'type' => 'document_root'
 };
+$result_trees{'braces_after_text'}{'contents'}[0]{'contents'}[2]{'contents'}[1]{'extra'}{'def_index_element'}
 = 
$result_trees{'braces_after_text'}{'contents'}[0]{'contents'}[2]{'contents'}[1]{'args'}[0]{'contents'}[2];
 
 $result_texis{'braces_after_text'} = '@linemacro mymacro {a, b, c}
-expand \\a\\ \\b\\ \\c\\
+@defline \\a\\ \\b\\ \\c\\
 @end linemacro
 
-expand text in paren restin paren 
+@defblock
+@defline text{in paren} rest{in paren} 
+@end defblock
 ';
 
 
 $result_texts{'braces_after_text'} = '
-expand text in paren restin paren 
+textin paren: restin paren
 ';
 
-$result_errors{'braces_after_text'} = [
-  {
-    'error_line' => 'misplaced { (possibly involving @mymacro)
-',
-    'file_name' => '',
-    'line_nr' => 5,
-    'macro' => 'mymacro',
-    'text' => 'misplaced {',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced } (possibly involving @mymacro)
-',
-    'file_name' => '',
-    'line_nr' => 5,
-    'macro' => 'mymacro',
-    'text' => 'misplaced }',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced { (possibly involving @mymacro)
-',
-    'file_name' => '',
-    'line_nr' => 5,
-    'macro' => 'mymacro',
-    'text' => 'misplaced {',
-    'type' => 'error'
-  },
-  {
-    'error_line' => 'misplaced } (possibly involving @mymacro)
-',
-    'file_name' => '',
-    'line_nr' => 5,
-    'macro' => 'mymacro',
-    'text' => 'misplaced }',
-    'type' => 'error'
-  }
-];
+$result_errors{'braces_after_text'} = [];
 
 
 $result_floats{'braces_after_text'} = {};
diff --git a/tp/t/results/linemacro/spaces_in_call.pl 
b/tp/t/results/linemacro/spaces_in_call.pl
index 68e8381368..21d80679ca 100644
--- a/tp/t/results/linemacro/spaces_in_call.pl
+++ b/tp/t/results/linemacro/spaces_in_call.pl
@@ -104,26 +104,31 @@ $result_trees{'spaces_in_call'} = {
                       {
                         'contents' => [
                           {
-                            'text' => 'a b'
-                          }
-                        ],
-                        'type' => 'bracketed_arg'
-                      },
-                      {
-                        'contents' => [
+                            'contents' => [
+                              {
+                                'text' => 'a b'
+                              }
+                            ],
+                            'type' => 'bracketed_arg'
+                          },
                           {
-                            'text' => 'c d'
-                          }
-                        ],
-                        'type' => 'bracketed_arg'
-                      },
-                      {
-                        'contents' => [
+                            'contents' => [
+                              {
+                                'text' => 'c d'
+                              }
+                            ],
+                            'type' => 'bracketed_arg'
+                          },
                           {
-                            'text' => 'rest'
+                            'contents' => [
+                              {
+                                'text' => 'rest'
+                              }
+                            ],
+                            'type' => 'bracketed_arg'
                           }
                         ],
-                        'type' => 'bracketed_arg'
+                        'type' => 'def_aggregate'
                       }
                     ],
                     'info' => {
@@ -179,23 +184,51 @@ $result_trees{'spaces_in_call'} = {
                       'type' => 'spaces'
                     },
                     {
+                      'contents' => [
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'a b'
+                            }
+                          ],
+                          'source_info' => {
+                            'file_name' => '',
+                            'line_nr' => 7,
+                            'macro' => 'mylinecommand'
+                          },
+                          'type' => 'bracketed_arg'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'c d'
+                            }
+                          ],
+                          'source_info' => {
+                            'file_name' => '',
+                            'line_nr' => 7,
+                            'macro' => 'mylinecommand'
+                          },
+                          'type' => 'bracketed_arg'
+                        },
+                        {
+                          'contents' => [
+                            {
+                              'text' => 'rest'
+                            }
+                          ],
+                          'source_info' => {
+                            'file_name' => '',
+                            'line_nr' => 7,
+                            'macro' => 'mylinecommand'
+                          },
+                          'type' => 'bracketed_arg'
+                        }
+                      ],
                       'extra' => {
                         'def_role' => 'name'
                       },
-                      'text' => 'a'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'spaces'
-                      },
-                      'text' => ' ',
-                      'type' => 'spaces'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'arg'
-                      },
-                      'text' => 'b'
+                      'type' => 'def_aggregate'
                     },
                     {
                       'extra' => {
@@ -214,33 +247,7 @@ $result_trees{'spaces_in_call'} = {
                       'extra' => {
                         'def_role' => 'spaces'
                       },
-                      'text' => ' ',
-                      'type' => 'spaces'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'arg'
-                      },
-                      'text' => 'c'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'spaces'
-                      },
-                      'text' => ' ',
-                      'type' => 'spaces'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'arg'
-                      },
-                      'text' => 'd'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'spaces'
-                      },
-                      'text' => ' ',
+                      'text' => '  ',
                       'type' => 'spaces'
                     },
                     {
@@ -248,24 +255,11 @@ $result_trees{'spaces_in_call'} = {
                         'def_role' => 'arg'
                       },
                       'text' => 'B'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'spaces'
-                      },
-                      'text' => ' ',
-                      'type' => 'spaces'
-                    },
-                    {
-                      'extra' => {
-                        'def_role' => 'arg'
-                      },
-                      'text' => 'rest'
                     }
                   ],
                   'info' => {
                     'spaces_after_argument' => {
-                      'text' => '
+                      'text' => ' 
 '
                     }
                   },
@@ -351,13 +345,13 @@ $result_texis{'spaces_in_call'} = '@linemacro 
mylinecommand {first, second, rest
 @end linemacro
 
 @defblock
-@defline category a b A c d B rest
+@defline category {a b}{c d}{rest} A  B 
 @end defblock
 ';
 
 
 $result_texts{'spaces_in_call'} = '
-category: a b A c d B rest
+category: a bc drest A  B
 ';
 
 $result_errors{'spaces_in_call'} = [];



reply via email to

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