[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7501] parsetexi update
From: |
gavinsmith0123 |
Subject: |
[7501] parsetexi update |
Date: |
Thu, 10 Nov 2016 18:36:28 +0000 (UTC) |
Revision: 7501
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7501
Author: gavin
Date: 2016-11-10 18:36:28 +0000 (Thu, 10 Nov 2016)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/tp/parsetexi/Parsetexi.pm
trunk/tp/parsetexi/Parsetexi.xs
trunk/tp/parsetexi/api.c
trunk/tp/parsetexi/dump_perl.c
trunk/tp/parsetexi/end_line.c
trunk/tp/parsetexi/labels.c
trunk/tp/parsetexi/labels.h
trunk/tp/parsetexi/menus.c
trunk/tp/parsetexi/tree_types.h
Modified: trunk/tp/parsetexi/Parsetexi.pm
===================================================================
--- trunk/tp/parsetexi/Parsetexi.pm 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/Parsetexi.pm 2016-11-10 18:36:28 UTC (rev 7501)
@@ -104,6 +104,7 @@
my %parser_blanks = (
'labels' => {},
+ 'targets' => [],
'extra' => {},
'info' => {},
'index_names' => {},
@@ -262,6 +263,29 @@
}
}
+sub get_parser_info {
+ my $self = shift;
+
+ my ($TARGETS, $INTL_XREFS, $FLOATS,
+ $INDEX_NAMES, $ERRORS, $GLOBAL_INFO, $GLOBAL_INFO2);
+
+ $TARGETS = build_label_list ();
+ $INTL_XREFS = build_internal_xref_list ();
+ $FLOATS = build_float_list ();
+ $INDEX_NAMES = build_index_data ();
+ $GLOBAL_INFO = build_global_info ();
+ $GLOBAL_INFO2 = build_global_info2 ();
+
+ $self->{'targets'} = $TARGETS;
+ $self->{'labels'} = {};
+ $self->{'internal_references'} = $INTL_XREFS;
+ $self->{'floats'} = $FLOATS;
+ $self->{'info'} = $GLOBAL_INFO;
+ $self->{'extra'} = $GLOBAL_INFO2;
+
+ _get_errors ($self);
+}
+
# Replacement for Texinfo::Parser::parse_texi_file (line 835)
sub parse_texi_file ($$)
{
@@ -271,23 +295,9 @@
$self->{'info'}->{'input_file_name'} = $file_name;
- #print "Getting tree...\n";
-
- my ($TREE, $LABELS, $INTL_XREFS, $FLOATS,
- $INDEX_NAMES, $ERRORS, $GLOBAL_INFO, $GLOBAL_INFO2);
parse_file ($file_name);
- $TREE = build_texinfo_tree ();
-
-
- $LABELS = build_label_list ();
- $FLOATS = build_float_list ();
-
- $INDEX_NAMES = build_index_data ();
-
- $GLOBAL_INFO = build_global_info ();
-
- $GLOBAL_INFO2 = build_global_info2 ();
-
+ my $TREE = build_texinfo_tree ();
+ get_parser_info ($self);
_complete_node_list ($self, $TREE);
# line 899
@@ -328,9 +338,6 @@
############################################################
- $self->{'info'} = $GLOBAL_INFO;
- $self->{'extra'} = $GLOBAL_INFO2;
-
if (defined($self->{'info'}->{'input_encoding_name'})) {
my ($texinfo_encoding, $perl_encoding, $input_encoding)
= Texinfo::Encoding::encoding_alias(
@@ -339,12 +346,6 @@
}
$self->{'info'}->{'input_file_name'} = $file_name;
- $self->{'labels'} = $LABELS;
- $self->{'internal_references'} = $INTL_XREFS;
- $self->{'floats'} = $FLOATS;
-
- _get_errors ($self);
-
return $TREE;
}
@@ -393,24 +394,7 @@
}
}
- # TODO: This code is duplicated from parse_texi_file
-
- my $LABELS = build_label_list ();
- $self->{'labels'} = $LABELS;
-
- my $INTL_XREFS = build_internal_xref_list ();
- $self->{'internal_references'} = $INTL_XREFS;
-
- my $FLOATS = build_float_list ();
- $self->{'floats'} = $FLOATS;
-
- my $GLOBAL_INFO = build_global_info ();
- $self->{'info'} = $GLOBAL_INFO;
-
- my $GLOBAL_INFO2 = build_global_info2 ();
- $self->{'extra'} = $GLOBAL_INFO2;
-
- _get_errors ($self);
+ get_parser_info($self);
_complete_node_list ($self, $tree);
return $tree;
}
@@ -470,9 +454,72 @@
return $self->{'info'};
}
+# Setup labels and nodes info and return labels
+# FIXME : should share this with the non-XS code.
sub labels_information($)
{
my $self = shift;
+
+ if (!%{$self->{'labels'}}
+ and defined $self->{'targets'}) {
+ my %labels = ();
+ for my $target (@{$self->{'targets'}}) {
+ if ($target->{'cmdname'} eq 'node') {
+ if ($target->{'extra'}->{'nodes_manuals'}) {
+ for my $node_manual (@{$target->{'extra'}{'nodes_manuals'}}) {
+ if (defined $node_manual
+ and defined $node_manual->{'node_content'}) {
+ my $normalized =
Texinfo::Convert::NodeNameNormalization::normalize_node({'contents' =>
$node_manual->{'node_content'}});
+ $node_manual->{'normalized'} = $normalized;
+ }
+ }
+ }
+ }
+ if (defined $target->{'extra'}->{'node_content'}) {
+ my $normalized =
Texinfo::Convert::NodeNameNormalization::normalize_node({'contents' =>
$target->{'extra'}->{'node_content'}});
+
+ if ($normalized !~ /[^-]/) {
+ $self->line_error (sprintf($self->__("empty node name after
expansion `%s'"),
+ Texinfo::Convert::Texinfo::convert({'contents'
+ => $target->{'extra'}->{'node_content'}})),
+ $target->{'line_nr'});
+ delete $target->{'extra'}->{'node_content'};
+ } else {
+ if (defined $labels{$normalized}) {
+ $self->line_error(
+ sprintf($self->__("address@hidden `%s' previously defined"),
+ $target->{'cmdname'},
+ Texinfo::Convert::Texinfo::convert({'contents' =>
+ $target->{'extra'}->{'node_content'}})),
+ $target->{'line_nr'});
+ $self->line_error(
+ sprintf($self->__("here is the previous definition as
address@hidden"),
+ $labels{$normalized}->{'cmdname'}),
+ $labels{$normalized}->{'line_nr'});
+ delete $target->{'extra'}->{'node_content'};
+ } else {
+ $labels{$normalized} = $target;
+ $target->{'extra'}->{'normalized'} = $normalized;
+ if ($target->{'cmdname'} eq 'node') {
+ if ($target->{'extra'}
+ and $target->{'extra'}{'node_argument'}) {
+ $target->{'extra'}{'node_argument'}{'normalized'}
+ = $normalized;
+ }
+ push @{$self->{'nodes'}}, $target;
+ }
+ }
+ }
+ } else {
+ if ($target->{'cmdname'} eq 'node') {
+ $self->line_error (sprintf($self->__("empty argument in
address@hidden"),
+ $target->{'cmdname'}), $target->{'line_nr'});
+ delete $target->{'extra'}->{'node_content'};
+ }
+ }
+ }
+ $self->{'labels'} = \%labels;
+ }
return $self->{'labels'};
}
Modified: trunk/tp/parsetexi/Parsetexi.xs
===================================================================
--- trunk/tp/parsetexi/Parsetexi.xs 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/Parsetexi.xs 2016-11-10 18:36:28 UTC (rev 7501)
@@ -12,8 +12,8 @@
#include "macro.h"
HV *build_texinfo_tree (void);
-HV *build_label_list (void);
-SV *build_internal_xref_list (void);
+AV *build_label_list (void);
+AV *build_internal_xref_list (void);
HV *build_float_list (void);
HV *build_index_data (void);
HV *build_global_info (void);
@@ -102,10 +102,10 @@
HV *
build_texinfo_tree ()
-HV *
+AV *
build_label_list ()
-SV *
+AV *
build_internal_xref_list ()
HV *
Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/api.c 2016-11-10 18:36:28 UTC (rev 7501)
@@ -178,11 +178,6 @@
build_perl_array (&value->node_content->contents), 0);
}
- if (value->normalized && *value->normalized)
- {
- hv_store (hv, "normalized", strlen ("normalized"),
- newSVpv (value->normalized, 0), 0);
- }
return newRV_inc ((SV *)hv);
}
@@ -567,31 +562,29 @@
return Root->hv;
}
-/* Return hash object from label names to target elements. build_texinfo_tree
- must be called first. */
-HV *
+/* Return array of target elements. build_texinfo_tree must
+ be called first. */
+AV *
build_label_list (void)
{
- HV *label_hash;
+ AV *target_array;
SV *sv;
int i;
dTHX;
- label_hash = newHV ();
+ target_array = newAV ();
for (i = 0; i < labels_number; i++)
{
sv = newRV_inc (labels_list[i].target->hv);
- hv_store (label_hash,
- labels_list[i].label, strlen (labels_list[i].label),
- sv, 0);
+ av_push (target_array, sv);
}
- return label_hash;
+ return target_array;
}
-SV *
+AV *
build_internal_xref_list (void)
{
AV *list_av;
@@ -608,7 +601,7 @@
av_push (list_av, sv);
}
- return newRV_inc ((SV *) list_av);
+ return list_av;
}
/* Return hash for list of @float's that appeared in the file. */
Modified: trunk/tp/parsetexi/dump_perl.c
===================================================================
--- trunk/tp/parsetexi/dump_perl.c 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/dump_perl.c 2016-11-10 18:36:28 UTC (rev 7501)
@@ -204,13 +204,6 @@
text_append (text, "'node_content' => ");
dump_contents (value->node_content, text);
}
- if (value->normalized)
- {
- dump_indent (text);
- text_append (text, "'normalized' => '");
- dump_string (value->normalized, text);
- text_append_n (text, "'\n", 2);
- }
indent -= 2;
dump_indent (text);
text_append_n (text, "},\n", 3);
@@ -539,16 +532,15 @@
{
int i;
- text_append (&fixup_dump, "\n$LABELS = {\n");
+ text_append (&fixup_dump, "\n$TARGETS = [\n");
for (i = 0; i < labels_number; i++)
{
- text_printf (&fixup_dump, "'%s' => ", labels_list[i].label);
dump_route_to_element (labels_list[i].target, &fixup_dump);
text_append (&fixup_dump, ",\n");
}
- text_append (&fixup_dump, "};\n");
+ text_append (&fixup_dump, "];\n");
}
static void
Modified: trunk/tp/parsetexi/end_line.c
===================================================================
--- trunk/tp/parsetexi/end_line.c 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/end_line.c 2016-11-10 18:36:28 UTC (rev 7501)
@@ -899,12 +899,10 @@
trimmed->parent_type = route_not_in_tree;
trimmed->parent = node;
result->node_content = trimmed;
- result->normalized = convert_to_normalized (trimmed);
}
else
{
result->node_content = 0;
- result->normalized = "";
destroy_element (trimmed);
}
return result;
@@ -1052,14 +1050,7 @@
float_label = parse_node_manual (args_child_by_index (f, 1));
// TODO check_internal_node
- if (float_label
- && float_label->node_content
- && *(float_label->normalized
- + strspn (float_label->normalized, "-")) != '\0')
- {
- /* TODO: Why check if there is a character that isn't '-'? */
- register_label (f, float_label);
- }
+ register_label (f, float_label);
}
parse_float_type (f);
k = lookup_extra_key (f, "type");
@@ -1638,14 +1629,9 @@
add_extra_node_spec_array (current, "nodes_manuals", nodes_manuals);
- /* Also set 'normalized' here. The normalized labels are actually
- the keys of "labels_information($parser)". */
- //nodes_manuals[0]->normalized
- // = convert_to_normalized (nodes_manuals[0]->node_content);
-
- /*Check that the node name doesn't have a filename element for
- referring to an external manual (_check_internal_node), and that it
- is not empty (_check_empty_node). */
+ /*Check that the node name doesn't have a filename element for referring
+ to an external manual (_check_internal_node), and that it is not empty
+ (_check_empty_node). */
//check_node_label ();
if (nodes_manuals[0])
Modified: trunk/tp/parsetexi/labels.c
===================================================================
--- trunk/tp/parsetexi/labels.c 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/labels.c 2016-11-10 18:36:28 UTC (rev 7501)
@@ -31,12 +31,6 @@
void
register_label (ELEMENT *current, NODE_SPEC_EXTRA *label)
{
- char *normalized = label->normalized;
-
- // 2494 TODO: check whether previously defined
-
- if (!normalized)
- return;
if (labels_number == labels_space)
{
labels_space += 1;
@@ -45,11 +39,9 @@
if (!labels_list)
abort ();
}
- labels_list[labels_number].label = normalized;
labels_list[labels_number++].target = current;
// 2504
- add_extra_string (current, "normalized", normalized);
add_extra_contents (current, "node_content", label->node_content);
}
Modified: trunk/tp/parsetexi/labels.h
===================================================================
--- trunk/tp/parsetexi/labels.h 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/labels.h 2016-11-10 18:36:28 UTC (rev 7501)
@@ -1,4 +1,4 @@
-/* Copyright 2010, 2011, 2012, 2013, 2014, 2015
+/* Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -16,11 +16,6 @@
/* Information about a possible target of a cross-reference, often a node. */
typedef struct {
- /* The normalized node name for HTML output of the target, used as a key.
- Using the normalized node name as a key is a way to avoid clashes if
- different node names containing @-commands end up as the same. */
- char *label;
-
/* Pointer to the element for the command defining this label, usually a
node element. FIXME: I'm not sure if we actualy need to get to the
target - much of the use of the labels_information is to check that
Modified: trunk/tp/parsetexi/menus.c
===================================================================
--- trunk/tp/parsetexi/menus.c 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/menus.c 2016-11-10 18:36:28 UTC (rev 7501)
@@ -76,8 +76,9 @@
add_to_element_args (current, description);
register_extra_menu_entry_information (current);
current->line_nr = line_nr;
+ remember_internal_xref (current);
+
current = description;
-
preformatted = new_element (ET_preformatted);
add_to_element_contents (current, preformatted);
current = preformatted;
@@ -85,8 +86,8 @@
return current;
}
-/* Called from 'big_loop' in parser.c. Return 1 if we find menu syntax to
- process, otherwise return 0. */
+/* 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)
{
Modified: trunk/tp/parsetexi/tree_types.h
===================================================================
--- trunk/tp/parsetexi/tree_types.h 2016-11-09 00:29:28 UTC (rev 7500)
+++ trunk/tp/parsetexi/tree_types.h 2016-11-10 18:36:28 UTC (rev 7501)
@@ -1,4 +1,4 @@
-/* Copyright 2010, 2011, 2012, 2013, 2014, 2015
+/* Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -201,7 +201,6 @@
typedef struct {
ELEMENT *manual_content;
ELEMENT *node_content;
- char *normalized;
} NODE_SPEC_EXTRA;
typedef struct {
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7501] parsetexi update,
gavinsmith0123 <=