[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7116] parsetexi work on floats
From: |
Gavin D. Smith |
Subject: |
[7116] parsetexi work on floats |
Date: |
Wed, 13 Apr 2016 18:53:55 +0000 |
Revision: 7116
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7116
Author: gavin
Date: 2016-04-13 18:53:55 +0000 (Wed, 13 Apr 2016)
Log Message:
-----------
parsetexi work on floats
Modified Paths:
--------------
trunk/tp/parsetexi/Parsetexi.pm
trunk/tp/parsetexi/Parsetexi.xs
trunk/tp/parsetexi/README
trunk/tp/parsetexi/api.c
trunk/tp/parsetexi/commands.h
trunk/tp/parsetexi/end_line.c
trunk/tp/parsetexi/handle_commands.c
trunk/tp/parsetexi/parser.h
Modified: trunk/tp/parsetexi/Parsetexi.pm
===================================================================
--- trunk/tp/parsetexi/Parsetexi.pm 2016-04-10 17:18:54 UTC (rev 7115)
+++ trunk/tp/parsetexi/Parsetexi.pm 2016-04-13 18:53:55 UTC (rev 7116)
@@ -109,9 +109,9 @@
'index_names' => {},
'merged_indices' => {},
'nodes' => [],
+ 'floats' => {},
# These aren't implemented yet.
- 'floats' => {},
'internal_references' => [],
# Not used but present in case we pass the object into
@@ -283,7 +283,8 @@
#print "Getting tree...\n";
- my ($TREE, $LABELS, $INDEX_NAMES, $ERRORS, $GLOBAL_INFO);
+ my ($TREE, $LABELS, $FLOATS,
+ $INDEX_NAMES, $ERRORS, $GLOBAL_INFO);
if (1) {
# This is our third way of passing the data: construct it using
# Perl api directly.
@@ -295,6 +296,7 @@
#print Texinfo::Parser::_print_tree ($TREE);
$LABELS = build_label_list ();
+ $FLOATS = build_float_list ();
$INDEX_NAMES = build_index_data ();
@@ -398,6 +400,7 @@
$self->{'info'}->{'input_file_name'} = $file_name;
$self->{'labels'} = $LABELS;
+ $self->{'floats'} = $FLOATS;
#$self->{'index_names'} = $INDEX_NAMES;
#for my $index (keys %$INDEX_NAMES) {
@@ -466,6 +469,9 @@
my $LABELS = build_label_list ();
$self->{'labels'} = $LABELS;
+ my $FLOATS = build_float_list ();
+ $self->{'floats'} = $FLOATS;
+
_get_errors ($self);
_add_parents ($tree);
_complete_node_list ($self, $tree);
Modified: trunk/tp/parsetexi/Parsetexi.xs
===================================================================
--- trunk/tp/parsetexi/Parsetexi.xs 2016-04-10 17:18:54 UTC (rev 7115)
+++ trunk/tp/parsetexi/Parsetexi.xs 2016-04-13 18:53:55 UTC (rev 7116)
@@ -13,6 +13,7 @@
HV *build_texinfo_tree (void);
HV *build_label_list (void);
+HV *build_float_list (void);
HV *build_index_data (void);
HV *build_global_info (void);
@@ -103,6 +104,9 @@
build_label_list ()
HV *
+build_float_list ()
+
+HV *
build_index_data ()
HV *
Modified: trunk/tp/parsetexi/README
===================================================================
--- trunk/tp/parsetexi/README 2016-04-10 17:18:54 UTC (rev 7115)
+++ trunk/tp/parsetexi/README 2016-04-13 18:53:55 UTC (rev 7116)
@@ -12,6 +12,12 @@
./configure PERL_EXT_CFLAGS='-g -O0'
+For individual tests can do "gdb perl" followed by e.g.
+
+(gdb) r -w t/27float.t comment_space_comand_in_float
+
+After a single run can set breakpoints.
+
How to debug with valgrind -
export PERL5LIB to the value in the makeinfo script
Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c 2016-04-10 17:18:54 UTC (rev 7115)
+++ trunk/tp/parsetexi/api.c 2016-04-13 18:53:55 UTC (rev 7116)
@@ -50,7 +50,7 @@
void
parse_file (char *filename)
{
- debug_output = 0;
+ debug_output = 1;
reset_parser ();
parse_texi_file (filename);
}
@@ -547,6 +547,46 @@
return label_hash;
}
+/* Return hash for list of @float's that appeared in the file. */
+HV *
+build_float_list (void)
+{
+ HV *float_hash;
+ SV **type_array;
+ SV *sv;
+ AV *av;
+ int i;
+
+ dTHX;
+
+ float_hash = newHV ();
+
+ for (i = 0; i < floats_number; i++)
+ {
+ type_array = hv_fetch (float_hash,
+ floats_list[i].type,
+ strlen (floats_list[i].type),
+ 0);
+ if (!type_array)
+ {
+ av = newAV ();
+ hv_store (float_hash,
+ floats_list[i].type,
+ strlen (floats_list[i].type),
+ newRV_inc ((SV *)av),
+ 0);
+ }
+ else
+ {
+ av = (AV *)SvRV (*type_array);
+ }
+ sv = newRV_inc ((SV *)floats_list[i].element->hv);
+ av_push (av, sv);
+ }
+
+ return float_hash;
+}
+
/* Ensure that I->hv is a hash value for a single entry in
$self->{'index_names'}, containing information about a single index. */
static void
Modified: trunk/tp/parsetexi/commands.h
===================================================================
--- trunk/tp/parsetexi/commands.h 2016-04-10 17:18:54 UTC (rev 7115)
+++ trunk/tp/parsetexi/commands.h 2016-04-13 18:53:55 UTC (rev 7116)
@@ -17,7 +17,7 @@
typedef struct command_struct {
char *cmdname;
unsigned long flags; /* Up to 32 flags */
- int data; /* Number of arguments for brace commands. */
+ int data; /* Number of arguments for brace or line commands. */
} COMMAND;
extern COMMAND builtin_command_data[];
Modified: trunk/tp/parsetexi/end_line.c
===================================================================
--- trunk/tp/parsetexi/end_line.c 2016-04-10 17:18:54 UTC (rev 7115)
+++ trunk/tp/parsetexi/end_line.c 2016-04-13 18:53:55 UTC (rev 7116)
@@ -832,6 +832,11 @@
return result;
}
+/* Array of recorded @float's. */
+FLOAT_RECORD *floats_list = 0;
+size_t floats_number = 0;
+size_t floats_space = 0;
+
int
parse_float_type (ELEMENT *current)
{
@@ -956,17 +961,42 @@
if (current->parent->cmd == CM_float) // 2943
{
+ ELEMENT *f = current->parent;
+ char *type = "";
current->parent->line_nr = line_nr;
if (current->parent->args.number > 0)
{
+ KEY_PAIR *k;
if (current->parent->args.number > 1)
{
- // TODO 2950
+ // 2950
+ NODE_SPEC_EXTRA *float_label;
+ 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);
+ }
}
- parse_float_type (current->parent);
- //type = ;
+ parse_float_type (f);
+ k = lookup_extra_key (f, "normalized");
+ if (k)
+ type = (char *) k->value;
}
- // add to global 'floats' array and set 'float_section' directly
+ // add to global 'floats' array
+ if (floats_number == floats_space)
+ {
+ floats_list = realloc (floats_list,
+ (floats_space += 5) * sizeof (FLOAT_RECORD));
+ }
+ floats_list[floats_number].type = type;
+ floats_list[floats_number++].element = f;
+ // set 'float_section' directly
// on $float.
}
current = current->parent; //2965
Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c 2016-04-10 17:18:54 UTC (rev
7115)
+++ trunk/tp/parsetexi/handle_commands.c 2016-04-13 18:53:55 UTC (rev
7116)
@@ -696,6 +696,14 @@
{
ELEMENT *bla = new_element (ET_block_line_arg);
add_to_element_args (current, bla);
+
+ if (command_data (current->cmd).data > 1)
+ {
+ counter_push (&count_remaining_args,
+ current,
+ command_data (current->cmd).data - 1);
+ }
+
current = bla;
if (!(command_data(cmd).flags & CF_def))
push_context (ct_line);
Modified: trunk/tp/parsetexi/parser.h
===================================================================
--- trunk/tp/parsetexi/parser.h 2016-04-10 17:18:54 UTC (rev 7115)
+++ trunk/tp/parsetexi/parser.h 2016-04-13 18:53:55 UTC (rev 7116)
@@ -26,6 +26,15 @@
ELEMENT *end_line (ELEMENT *current);
ELEMENT *parse_special_misc_command (char *line, enum command_id cmd);
+typedef struct {
+ char *type;
+ ELEMENT *element;
+} FLOAT_RECORD;
+
+extern FLOAT_RECORD *floats_list;
+extern size_t floats_number;
+extern size_t floats_space;
+
/* In debug.c */
void debug (char *s, ...);
void debug_nonl (char *s, ...);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7116] parsetexi work on floats,
Gavin D. Smith <=