[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * tp/Texinfo/ParserNonXS.pm (parse_texi_line), tp
From: |
Patrice Dumas |
Subject: |
branch master updated: * tp/Texinfo/ParserNonXS.pm (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_text) (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_string, parse_text), tp/Texinfo/XS/parsetexi/api.c (parse_string, parse_text): add a line number argument to the XS parser parse_string() and parse_text() functions and update accordingly the callers. Set line number to 1 in the default case for parse_texi_line(). |
Date: |
Sun, 09 Jan 2022 07:35:33 -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 ac122ac9a2 * tp/Texinfo/ParserNonXS.pm (parse_texi_line),
tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_text) (parse_texi_line),
tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_string, parse_text),
tp/Texinfo/XS/parsetexi/api.c (parse_string, parse_text): add a line number
argument to the XS parser parse_string() and parse_text() functions and update
accordingly the callers. Set line number to 1 in the default case for
parse_texi_line().
ac122ac9a2 is described below
commit ac122ac9a2fe87eb9f6a83bbf406f3680002408a
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Jan 9 13:35:23 2022 +0100
* tp/Texinfo/ParserNonXS.pm (parse_texi_line),
tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_text)
(parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs
(parse_string, parse_text), tp/Texinfo/XS/parsetexi/api.c
(parse_string, parse_text): add a line number argument to the XS
parser parse_string() and parse_text() functions and update
accordingly the callers. Set line number to 1 in the default case
for parse_texi_line().
* tp/Texinfo/ParserNonXS.pm: update API documentation.
---
ChangeLog | 13 +++
tp/Texinfo/ParserNonXS.pm | 152 +++++++++++++++++++++++------------
tp/Texinfo/XS/parsetexi/Parsetexi.pm | 8 +-
tp/Texinfo/XS/parsetexi/Parsetexi.xs | 6 +-
tp/Texinfo/XS/parsetexi/api.c | 8 +-
tp/Texinfo/XS/parsetexi/api.h | 4 +-
tp/t/test_parse_texi_line.t | 4 +-
7 files changed, 131 insertions(+), 64 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index fcc3528ca0..2a07409075 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2022-01-09 Patrice Dumas <pertusus@free.fr>
+
+ * tp/Texinfo/ParserNonXS.pm (parse_texi_line),
+ tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_text)
+ (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs
+ (parse_string, parse_text), tp/Texinfo/XS/parsetexi/api.c
+ (parse_string, parse_text): add a line number argument to the XS
+ parser parse_string() and parse_text() functions and update
+ accordingly the callers. Set line number to 1 in the default case
+ for parse_texi_line().
+
+ * tp/Texinfo/ParserNonXS.pm: update API documentation.
+
2022-01-09 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/ParserNonXS.pm (_parse_texi),
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index af077a35b8..737a26c7b9 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -1017,7 +1017,7 @@ sub parse_texi_line($$;$$$$)
$text = _text_to_lines($text);
}
if (not defined($lines_nr)) {
- $lines_nr = 0;
+ $lines_nr = 1;
}
my $lines_array = _complete_line_nr($text, $lines_nr, $file,
@@ -2601,6 +2601,9 @@ sub _enter_index_entry($$$$$$$)
my $number = (defined($index->{'index_entries'})
? (scalar(@{$index->{'index_entries'}}) + 1)
: 1);
+ # FIXME index_type_command does not seems to be used anywhere.
+ # It appears in test results tree, so maybe it is worth keeping
+ # it to be able to understand changes.
my $index_entry = { 'index_name' => $index_name,
'index_at_command' => $command,
'index_type_command' => $command_container,
@@ -6032,6 +6035,11 @@ Handle cpp like synchronization lines if set. Set in the
default case.
An array reference of the output formats for which C<@ifI<FORMAT>>
conditional blocks should be expanded. Default is empty.
+=item FORMAT_MENU
+
+Possible values are 'nomenu', 'menu' and 'sectiontoc'. Only report
+menu-related errors for 'menu'.
+
=item INCLUDE_DIRECTORIES
An array reference of directories in which C<@include> files should be
@@ -6046,15 +6054,6 @@ Default on.
Maximal number of nested user-defined macro calls. Default is 100000.
-=item FORMAT_MENU
-
-Possible values are 'nomenu', 'menu' and 'sectiontoc'. Only report
-menu-related errors for 'menu'.
-
-=item registrar
-
-Texinfo::Report object reused by the parser to register errors.
-
=begin comment
Duplicated in gdt() but not implemented in the XS Parser, so not
@@ -6079,6 +6078,10 @@ It overrides the document C<@documentlanguage>
informations, if present.
As if C<@novalidate> appeared at the beginning of the document.
+=item registrar
+
+Texinfo::Report object reused by the parser to register errors.
+
=item values
A hash reference. Keys are names, values are the corresponding values.
@@ -6102,12 +6105,27 @@ When C<parse_texi_line> is used, the resulting tree is
rooted at
a C<root_line> type container. Otherwise, the resulting tree should be
rooted at a C<document_root> type container.
-=over
+=begin comment
+
+The XS parser implements only part of the arguments and allows only a
+restricted set of arguments types compared to the perl parser. We want users
+to use only what is in common, so document only what is in common.
=item $tree = parse_texi_line($parser, $text, $first_line_number, $file_name,
$macro_name, $fixed_line_number)
+=end comment
+
+=over
+
+=item $tree = parse_texi_line($parser, $text, $first_line_number)
+
This function is used to parse a short fragment of Texinfo code.
+I<$text> is the string containing the texinfo line. I<$first_line_number> is
+the line number of the line, if undef, it will be set to 1.
+
+=begin comment
+
I<$text> may be either an array reference of lines, or a text.
The other arguments are optional and allow specifying the position
@@ -6118,10 +6136,27 @@ is expanded from. If I<$fixed_line_number> is set, the
line number is
not increased for the different lines, as if the text was the expansion
of a macro.
+=end comment
+
+=begin comment
+
+The XS parser implements only part of the arguments and allows only a
+restricted set of arguments types compared to the perl parser. We want users
+to use only what is in common, so document only what is in common.
+
=item $tree = parse_texi_text ($parser, $text, $line_numbers_specification,
$file_name, $macro_name, $fixed_line_number)
+=end comment
+
+=item $tree = parse_texi_text ($parser, $text, $first_line_number)
+
This function is used to parse some Texinfo text.
+I<$text> is the string containing the texinfo text. I<$first_line_number> is
+the line number of the first text line, if undef, it will be set to 1.
+
+=begin comment
+
I<$text> may be either an array reference of lines, or a text.
The other arguments are optional and allow specifying the position
@@ -6138,15 +6173,15 @@ the position information of each text line.
=item 2.
If I<$line_numbers_specification> is a scalar, it is the line number of
-the first text line. In that case (like for C<parse_texi_text>),
-I<$file_name> is the name of the file the text comes from.
-and I<$macro> is for the user-defined macro name the text
-is expanded from. If I<$fixed_line_number> is set, the line number is
-not increased for the different lines, as if the text was the expansion
-of a macro.
+the first text line. In that case I<$file_name> is the name of the file the
+text comes from. and I<$macro> is for the user-defined macro name the text is
+expanded from. If I<$fixed_line_number> is set, the line number is not
+increased for the different lines, as if the text was the expansion of a macro.
=back
+=end comment
+
=item $tree = parse_texi_file($parser, $file_name)
The file with name I<$file_name> is considered to be a Texinfo file and
@@ -6188,9 +6223,10 @@ The I<$info> returned is a hash reference. The possible
keys are
=over
-=item input_file_name
+=item dircategory_direntry
-The name of the main Texinfo input file.
+An array of successive C<@dircategory> and C<@direntry> as they appear
+in the document.
=item input_encoding_name
@@ -6200,10 +6236,9 @@ C<input_encoding_name> string is the encoding name used
for the
Texinfo code.
C<input_perl_encoding> string is a corresponding perl encoding name.
-=item dircategory_direntry
+=item input_file_name
-An array of successive C<@dircategory> and C<@direntry> as they appear
-in the document.
+The name of the main Texinfo input file.
=item novalidate
@@ -6329,10 +6364,23 @@ The index name.
The name of the @-command associated with the index entry.
+=item index_ignore_chars
+
+A hash reference with characters as keys and 1 as value. Corresponds to
+the characters flaggued as ignored in key sorting in the document by
+setting flags such as I<txiindexbackslashignore>.
+
+=begin comment
+
+This is not used anywhere, do not document to be able to remove it
+anytime.
+
=item index_type_command
-The @-command associated with the index entry allowing to
-find the index type.
+The name of the @-command associated with the index entry. This
+should allow to find the index associated to the index entry.
+
+=end comment
=item content
@@ -6506,7 +6554,7 @@ contents, I<line_arg> and I<block_line_arg> contain the
arguments
appearing on the line of @-commands. Text fragments may have a type to
give an information of the kind of text fragment, for example
I<empty_spaces_before_argument> is associated to spaces after a brace
-opening and before the argument. Many @-commands elements don't have
+opening and before the argument. Many @-commands elements do not have
a type associated.
=item args
@@ -6640,11 +6688,12 @@ at all):
=over
-=item untranslated
+=item after_description_line
-English text added by the parser that may need to be translated
-during conversion. Happens for @def* @-commands aliases that
-leads to prepending text such as 'Function'.
+=item space_at_end_menu_node
+
+Space after a node in the menu entry, when there is no description,
+and space appearing after the description line.
=item empty_line
@@ -6659,45 +6708,51 @@ or spaces followed by a newline for
I<empty_line_after_command>, appearing after an @-command that
takes an argument on the line or a block @-command.
+=item empty_spaces_after_close_brace
+
+Spaces appearing after a closing brace, for some rare commands for which
+this space should be ignorable (like C<@caption>).
+
=item empty_spaces_before_argument
The text is spaces appearing after an opening brace or after a
comma separating a command's arguments.
-=item spaces_at_end
+=item empty_spaces_before_paragraph
-Space at the end of an argument to a line command, at the end of an
-comma-separated argument for some brace commands, or at the end of
-bracketed content on a C<@multitable> line or definition line.
+Space appearing before a paragraph beginning.
-=item empty_spaces_after_close_brace
+=item last_raw_newline
-Spaces appearing after a closing brace, for some rare commands for which
-this space should be ignorable (like C<@caption>).
+The last end of line in a raw block (except for C<@verbatim>).
-=item empty_spaces_before_paragraph
+=item misc_arg
-Space appearing before a paragraph beginning.
+Used for the arguments to some special line commands whose arguments
+aren't subject to the usual macro expansion. For example C<@set>,
+C<@clickstyle>, C<@unmacro>, C<@comment>. The argument is associated to
+the I<text> key.
=item raw
Text in an environment where it should be kept as is (in C<@verbatim>,
C<@verb>, C<@html>, C<@macro> body).
-=item last_raw_newline
+=item spaces_at_end
-The last end of line in a raw block (except for C<@verbatim>).
+Space at the end of an argument to a line command, at the end of an
+comma-separated argument for some brace commands, or at the end of
+bracketed content on a C<@multitable> line or definition line.
=item text_before_beginning
Text appearing before real content, including the C<\input texinfo.tex>.
-=item space_at_end_menu_node
-
-=item after_description_line
+=item untranslated
-Space after a node in the menu entry, when there is no description,
-and space appearing after the description line.
+English text added by the parser that may need to be translated
+during conversion. Happens for @def* @-commands aliases that
+leads to prepending text such as 'Function'.
=back
@@ -6775,13 +6830,6 @@ leads to
'args' => [{'type' => 'brace_command_arg',
'contents' => [{'text' => 'in code'}]}]}
-=item misc_arg
-
-Used for the arguments to some special line commands whose arguments
-aren't subject to the usual macro expansion. For example C<@set>,
-C<@clickstyle>, C<@unmacro>, C<@comment>. The argument is associated to
-the I<text> key.
-
=item menu_entry
=item menu_entry_leading_text
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
index 67f074e952..c72395a778 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.pm
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.pm
@@ -287,13 +287,15 @@ sub parse_texi_text($$;$$$$)
return undef if (!defined($text));
+ $lines_nr = 1 if (not defined($lines_nr));
+
$self = parser() if (!defined($self));
# make sure that internal byte buffer is in UTF-8 before we pass
# it in to the XS code.
utf8::upgrade($text);
- parse_text($text);
+ parse_text($text, $lines_nr);
my $tree = build_texinfo_tree ();
get_parser_info($self);
@@ -314,9 +316,11 @@ sub parse_texi_line($$;$$$$)
return undef if (!defined($text));
+ $lines_nr = 1 if (not defined($lines_nr));
+
$self = parser() if (!defined($self));
utf8::upgrade($text);
- parse_string($text);
+ parse_string($text, $lines_nr);
my $tree = build_texinfo_tree ();
_set_errors_node_lists_labels_indices($self);
diff --git a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
index 36dd3b9dc1..a60f0ce85a 100644
--- a/tp/Texinfo/XS/parsetexi/Parsetexi.xs
+++ b/tp/Texinfo/XS/parsetexi/Parsetexi.xs
@@ -37,12 +37,14 @@ parse_file(filename)
char * filename
void
-parse_string(string)
+parse_string(string, line_nr)
char * string
+ int line_nr
void
-parse_text(string)
+parse_text(string, line_nr)
char * string
+ int line_nr
void
store_value (name, value)
diff --git a/tp/Texinfo/XS/parsetexi/api.c b/tp/Texinfo/XS/parsetexi/api.c
index 4c7549125e..22f974b366 100644
--- a/tp/Texinfo/XS/parsetexi/api.c
+++ b/tp/Texinfo/XS/parsetexi/api.c
@@ -172,24 +172,24 @@ parse_file (char *filename)
/* Set ROOT to root of tree obtained by parsing the Texinfo code in STRING.
STRING should be a UTF-8 buffer. Used for parse_texi_line. */
void
-parse_string (char *string)
+parse_string (char *string, int line_nr)
{
ELEMENT *root_elt = new_element (ET_root_line);
reset_parser_except_conf ();
- input_push_text (strdup (string), 0);
+ input_push_text_with_line_nos (strdup (string), line_nr);
Root = parse_texi (root_elt, root_elt);
}
/* Used for parse_texi_text. STRING should be a UTF-8 buffer. */
void
-parse_text (char *string)
+parse_text (char *string, int line_nr)
{
ELEMENT *before_node_section = setup_document_root_and_before_node_section
();
ELEMENT *document_root = before_node_section->parent;
reset_parser_except_conf ();
- input_push_text_with_line_nos (strdup (string), 1);
+ input_push_text_with_line_nos (strdup (string), line_nr);
Root = parse_texi (document_root, before_node_section);
}
diff --git a/tp/Texinfo/XS/parsetexi/api.h b/tp/Texinfo/XS/parsetexi/api.h
index e86b535b26..ed6081b980 100644
--- a/tp/Texinfo/XS/parsetexi/api.h
+++ b/tp/Texinfo/XS/parsetexi/api.h
@@ -5,8 +5,8 @@ extern ELEMENT *Root;
int init (int texinfo_uninstalled, char *srcdir_in);
-void parse_text (char *);
-void parse_string(char *);
+void parse_text (char *, int line_nr);
+void parse_string(char *, int line_nr);
int parse_file (char *filename);
void reset_parser (void);
void reset_parser_except_conf (void);
diff --git a/tp/t/test_parse_texi_line.t b/tp/t/test_parse_texi_line.t
index 1d1cdaed07..e16545e444 100644
--- a/tp/t/test_parse_texi_line.t
+++ b/tp/t/test_parse_texi_line.t
@@ -48,9 +48,9 @@ sub test_line($$$$)
my @tests = (
["\@node a node\n", 'node line'],
["aa \@exdent in exdent", 'exdent error no end line',
- [':0: warning: @exdent should only appear at the beginning of a line']],
+ [':1: warning: @exdent should only appear at the beginning of a line']],
["aa \@exdent in exdent\n", 'exdent error with end line',
- [':0: warning: @exdent should only appear at the beginning of a line']],
+ [':1: warning: @exdent should only appear at the beginning of a line']],
);
foreach my $test_string_explanation (@tests) {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * tp/Texinfo/ParserNonXS.pm (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.pm (parse_texi_text) (parse_texi_line), tp/Texinfo/XS/parsetexi/Parsetexi.xs (parse_string, parse_text), tp/Texinfo/XS/parsetexi/api.c (parse_string, parse_text): add a line number argument to the XS parser parse_string() and parse_text() functions and update accordingly the callers. Set line number to 1 in the default case for parse_texi_line().,
Patrice Dumas <=