texinfo-commits
[Top][All Lists]
Advanced

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

[6045] parsetexi output index information


From: Gavin D. Smith
Subject: [6045] parsetexi output index information
Date: Thu, 15 Jan 2015 00:04:49 +0000

Revision: 6045
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6045
Author:   gavin
Date:     2015-01-15 00:04:47 +0000 (Thu, 15 Jan 2015)
Log Message:
-----------
parsetexi output index information

Modified Paths:
--------------
    trunk/parsetexi/ChangeLog
    trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
    trunk/parsetexi/commands.h
    trunk/parsetexi/dump_perl.c
    trunk/parsetexi/end_line.c
    trunk/parsetexi/extra.c
    trunk/parsetexi/indices.c
    trunk/parsetexi/main.c
    trunk/parsetexi/makeinfo-debug.txt
    trunk/parsetexi/parser.h
    trunk/parsetexi/tree_types.h

Added Paths:
-----------
    trunk/parsetexi/indices.h
    trunk/parsetexi/test-files/index.texi

Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog   2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/ChangeLog   2015-01-15 00:04:47 UTC (rev 6045)
@@ -1,5 +1,39 @@
-2014-01-21  Gavin Smith  <address@hidden>
+2015-01-14  Gavin Smith  <address@hidden>
 
+       First support of outputting an index.
+
+       * extra.c (add_extra_key_misc_args, add_extra_key_index_entry): 
+       New functions.
+       * tree_types.h (INDEX, INDEX_ENTRY): New types.
+       * commands.h (CF_index_entry_command): New flag.
+
+       * indices.c (associate_command_to_index, index_of_command): New
+       functions.
+       (init_index_commands): Call associate_command_to_index for each 
+       index command.
+       (enter_index_entry): New function.
+
+       * end_line.c (trim_spaces_comment_from_content): New function.
+       (end_line): Call it in two places.
+       (end_line) <misc args>: Add "misc_args" extra key, and call 
+       enter_index_entry for index commands.
+
+       * dump_perl.c (dump_indices_information): New function.
+       (dump_route_to_element): Take extra argument saying which text
+       buffer to write to.
+       (dump_extra): Handle two extra types of extra key, 
+       extra_index_entry and extra_misc_args.  For extra_index_entry, 
+       dump to tree_to_indices_dump variable.
+       (dump_tree_to_perl): Call dump_indices_information, and output
+       tree_to_indices_dump afterwards.
+
+       * Parsetexi/lib/Parsetexi.pm (parse_texi_file): Set 
+       'index_names' from output of parsetexi.
+
+       * test-files/index.texi: New test file.
+
+2015-01-12  Gavin Smith  <address@hidden>
+
        All files: Add copyright and licensing notices.
 
 2014-12-20  Gavin Smith  <address@hidden>

Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-01-14 21:36:21 UTC (rev 
6044)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-01-15 00:04:47 UTC (rev 
6045)
@@ -271,7 +271,7 @@
   # to Parsetexi.pm to get the tree without doing this.
   $tree_stream = qx(./parsetexi $file_name 2>/dev/null);
 
-  my ($TREE, $LABELS);
+  my ($TREE, $LABELS, $INDEX_NAMES);
   #print "Reading tree...\n";
   eval $tree_stream;
   #print "Read tree.\n";
@@ -285,6 +285,8 @@
 
   $self->{'labels'} = $LABELS;
 
+  $self->{'index_names'} = $INDEX_NAMES;
+
   #$Data::Dumper::Purity = 1;
   #$Data::Dumper::Indent = 1;
   #my $bar = Data::Dumper->Dump([$TREE], ['$TREE']);

Modified: trunk/parsetexi/commands.h
===================================================================
--- trunk/parsetexi/commands.h  2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/commands.h  2015-01-15 00:04:47 UTC (rev 6045)
@@ -72,7 +72,7 @@
 #define CF_blockitem                   0x08000000
 #define CF_inline                      0x10000000
 #define CF_MACRO                       0x20000000
-// #define free                        0x40000000
+#define CF_index_entry_command         0x40000000
 // #define free                        0x80000000
 
 /* Types of misc command (has CF_misc flag).  Values for COMMAND.data. */

Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/dump_perl.c 2015-01-15 00:04:47 UTC (rev 6045)
@@ -21,17 +21,21 @@
 #include "input.h"
 #include "text.h"
 #include "labels.h"
+#include "indices.h"
 
 #define element_type_name(e) element_type_names[(e)->type]
 
 #define TREE_ROOT_VAR "$TREE"
-#define LABELS_VAR "$LABELS"
 
 int indent = 0;
 
 /* A dump to fill in references from one part of the tree to another. */
 static TEXT fixup_dump;
 
+/* A dump to fill in references from the parse tree to the indices 
+   information.  */
+static TEXT tree_to_indices_dump;
+
 void dump_contents (ELEMENT *);
 void dump_element (ELEMENT *);
 void dump_args (ELEMENT *);
@@ -90,27 +94,27 @@
 }
 
 /* Recursively go up to the root of the tree.  On the way back print the path 
-   to the element into FIXUP_DUMP. */
+   to the element into DUMP. */
 void
-dump_route_to_element (ELEMENT *e)
+dump_route_to_element (ELEMENT *e, TEXT *dump)
 {
   if (e->parent)
-    dump_route_to_element (e->parent);
+    dump_route_to_element (e->parent, dump);
 
   switch (e->parent_type)
     {
     case route_args:
-      text_append (&fixup_dump, "{'args'}");
-      text_printf (&fixup_dump, "[%d]", e->index_in_parent);
+      text_append (dump, "{'args'}");
+      text_printf (dump, "[%d]", e->index_in_parent);
       break;
     case route_contents:
-      text_append (&fixup_dump, "{'contents'}");
-      text_printf (&fixup_dump, "[%d]", e->index_in_parent);
+      text_append (dump, "{'contents'}");
+      text_printf (dump, "[%d]", e->index_in_parent);
       break;
     case route_uninitialized:
       if (e->parent)
         abort ();
-      text_append (&fixup_dump, TREE_ROOT_VAR "->");
+      text_append (dump, TREE_ROOT_VAR "->");
       break;
     default:
       abort ();
@@ -121,11 +125,11 @@
 void
 dump_fixup_line (ELEMENT *e, int i)
 {
-  dump_route_to_element (e);
+  dump_route_to_element (e, &fixup_dump);
   text_printf (&fixup_dump, "{'extra'}{'%s'}", e->extra[i].key);
 
   text_append (&fixup_dump, " = ");
-  dump_route_to_element (e->extra[i].value);
+  dump_route_to_element (e->extra[i].value, &fixup_dump);
 
   switch (e->extra[i].type)
     {
@@ -162,8 +166,42 @@
         {
           dump_indent ();
 
-          if (e->extra[i].value->parent_type == route_not_in_tree)
+          if (e->extra[i].type == extra_index_entry)
             {
+              /* A "index_entry" extra key on a command defining an index
+                 entry.  Unlike the other keys, the value is not in the
+                 main parse tree, but in the indices_information.  It would
+                 be much nicer if we could get rid of the need for this key. */
+
+              INDEX_ENTRY *value = (INDEX_ENTRY *) e->extra[i].value;
+
+              dump_route_to_element (e, &tree_to_indices_dump);
+              text_printf (&tree_to_indices_dump, "{'extra'}{'%s'} = ",
+                           e->extra[i].key);
+              text_printf (&tree_to_indices_dump,
+                           "$INDEX_NAMES->{'%s'}{'index_entries'}[%d];\n",
+                           value->index_name, value->number - 1);
+              /* value->number is 1-based so we needed to subtract 1. */
+            }
+          else if (e->extra[i].type == extra_misc_args)
+            {
+              int j;
+              /* A "misc_args" value is just an array of strings. */
+              printf ("'%s' => [", e->extra[i].key);
+              for (j = 0; j < e->extra[i].value->contents.number; j++)
+                {
+                  if (e->extra[i].value->contents.list[j]->text.end > 0)
+                    {
+                      /* TODO: Escape special characters. */
+                      printf ("'%s',",
+                              e->extra[i].value->contents.list[j]->text.text);
+                    }
+                  /* else an error? */
+                }
+              printf ("],\n");
+            }
+          else if (e->extra[i].value->parent_type == route_not_in_tree)
+            {
               switch (e->extra[i].type)
                 {
                 case extra_element:
@@ -324,27 +362,101 @@
   printf ("}");
 }
 
-void
+static void
 dump_labels_information (void)
 {
   int i;
 
-  text_append (&fixup_dump, "\n" LABELS_VAR " = {\n");
+  text_append (&fixup_dump, "\n$LABELS = {\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);
+      dump_route_to_element (labels_list[i].target, &fixup_dump);
       text_append (&fixup_dump, ",\n");
     }
 
   text_append (&fixup_dump, "};\n");
 }
 
+static void
+dump_entries_of_index (INDEX *idx)
+{
+  int i;
+  INDEX_ENTRY *e;
+
+  text_printf (&fixup_dump, "\n'index_entries' => [");
+  for (i = 0; i < idx->index_number; i++)
+    {
+      e = &idx->index_entries[i];
+      text_printf (&fixup_dump, "\n{");
+      text_printf (&fixup_dump, "'index_name' => '%s',", e->index_name);
+      text_printf (&fixup_dump, "'index_prefix' => '%s',", e->index_prefix);
+
+      text_printf (&fixup_dump, "\n");
+      text_printf (&fixup_dump, "'index_at_command' => '%s',",
+                  command_data(e->index_at_command).cmdname);
+      text_printf (&fixup_dump, "'index_type_command' => '%s',\n", 
+                   command_data(e->index_type_command).cmdname);
+
+      text_printf (&fixup_dump, "'command' => ");
+      dump_route_to_element (e->command, &fixup_dump);
+      text_printf (&fixup_dump, ",\n");
+
+      if (e->content)
+        {
+          text_printf (&fixup_dump, "'content' => ");
+          dump_route_to_element (e->content, &fixup_dump);
+          text_printf (&fixup_dump, "{'contents'}");
+          text_printf (&fixup_dump, ",\n");
+        }
+
+      if (e->node)
+        {
+          text_printf (&fixup_dump, "'node' => ");
+          dump_route_to_element (e->node, &fixup_dump);
+          text_printf (&fixup_dump, ",\n");
+        }
+
+      text_printf (&fixup_dump, "},");
+    }
+  text_printf (&fixup_dump, "],\n");
+}
+
+static void
+dump_indices_information (void)
+{
+  INDEX *i;
+
+  text_append (&fixup_dump, "\n$INDEX_NAMES = {\n");
+  for (i = index_names; i->name; i++)
+    {
+      text_printf (&fixup_dump, "'%s' => {", i->name);
+      text_printf (&fixup_dump, "'name' => '%s',", i->name);
+      text_printf (&fixup_dump, "'in_code' => 0,");
+
+      /* TODO: This is a list of recognized prefixes for the index. */
+      text_printf (&fixup_dump, "'prefix' => ['%c', '%s'],",
+                   *i->name, i->name);
+
+      /* TODO: Handle index merging. */
+      text_printf (&fixup_dump, "'contained_indices' => {'%s'=>1},",
+                   i->name);
+
+      dump_entries_of_index (i);
+
+      text_printf (&fixup_dump, "},\n");
+    }
+
+  text_append (&fixup_dump, "};\n");
+}
+
 void
 dump_tree_to_perl (ELEMENT *root)
 {
   text_init (&fixup_dump);
+  text_init (&tree_to_indices_dump);
+
   printf (TREE_ROOT_VAR " = ");
   dump_element (root);
   printf (";\n");
@@ -353,6 +465,13 @@
 
   dump_labels_information ();
 
+  dump_indices_information ();
+
   if (fixup_dump.end > 0)
     printf ("%s", fixup_dump.text);
+
+  /* This must be output at the end so that both the tree and the indices
+     will exist by the time this is read. */
+  if (tree_to_indices_dump.end > 0)
+    printf ("%s", tree_to_indices_dump.text);
 }

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/end_line.c  2015-01-15 00:04:47 UTC (rev 6045)
@@ -23,7 +23,37 @@
 #include "input.h"
 #include "convert.h"
 #include "labels.h"
+#include "indices.h"
 
+/* Return a new element whose contents are the same as those of ORIGINAL,
+   but with some elements representing empty spaces removed.  Elements like 
+   these are used to represent some of the "content" extra keys. */
+ELEMENT *
+trim_spaces_comment_from_content (ELEMENT *original)
+{
+  ELEMENT *trimmed;
+  int i;
+
+  trimmed = new_element (ET_NONE);
+  trimmed->parent_type = route_not_in_tree;
+  for (i = 0; i < original->contents.number; i++)
+    {
+      if (original->contents.list[i]->type
+          != ET_empty_spaces_after_command
+          && original->contents.list[i]->type != ET_spaces_at_end)
+        {
+          /* FIXME: Is this safe to serialize? */
+          /* For example, if there are extra keys in the elements under each 
+             argument?  They may not be set in a copy.
+             Hopefully there aren't many extra keys set on commands in 
+             node names. */
+          add_to_element_contents (trimmed, original->contents.list[i]);
+        }
+    }
+
+  return trimmed;
+}
+
 /* 2610 */
 /* Actions to be taken when a whole line of input has been processed */
 ELEMENT *
@@ -252,9 +282,7 @@
 
       if (arg_type > 0)
         {
-          /* arg_type is number of args */
-          // parse_line_command_args
-          // save in 'misc_args' extra key
+          //parse_line_command_args (current);
         }
       else if (arg_type == MISC_text) /* 3118 */
         {
@@ -344,25 +372,8 @@
              in 'nodes_manuals'. */
           //parse_node_manual ();
           
-          /* In Perl a copy of the argument list is taken and the empty space 
-             arguments are removed with trim_spaces_comment_from_content. */
           first_arg = current->args.list[0];
-          arg = new_element (ET_NONE);
-          arg->parent_type = route_not_in_tree;
-          for (i = 0; i < first_arg->contents.number; i++)
-            {
-              if (first_arg->contents.list[i]->type
-                    != ET_empty_spaces_after_command
-                  && first_arg->contents.list[i]->type != ET_spaces_at_end)
-                {
-                  /* FIXME: Is this safe to serialize? */
-                  /* For example, if there are extra keys in the elements 
under 
-                     each argument?  They may not be set in a copy.
-                     Hopefully there aren't many extra keys set on commands in 
-                     node names. */
-                  add_to_element_contents (arg, first_arg->contents.list[i]);
-                }
-            }
+          arg = trim_spaces_comment_from_content (first_arg);
           add_extra_key_contents (current, "node_content", arg);
 
           /* Also set 'normalized' here.  The normalized labels are actually 
@@ -384,7 +395,31 @@
         }
       else
         {
+          ELEMENT *misc_args;
+
+          misc_args = trim_spaces_comment_from_content 
+            (last_args_child(current));
+
+          add_extra_key_misc_args (current, "misc_args", misc_args);
+
           /* All the other "line" commands" */
+          // 3273 - warning about missing argument
+
+          /* Index commands */
+          if (command_flags(current) & CF_index_entry_command)
+            {
+              /* TODO: Trim space elements from contents.  Note we aren't
+                 using the misc_args variable yet, because we have not
+                 got a way to serialize a pointer from the index information
+                 to a detached extra key that is not part of the main tree. */
+              ELEMENT *contents;
+              contents = last_args_child(current);
+
+              // 3274
+              enter_index_entry (current->cmd, current->cmd, current,
+                                 contents);
+              current->type = ET_index_entry_command;
+            }
         }
 
       current = current->parent; /* 3285 */

Modified: trunk/parsetexi/extra.c
===================================================================
--- trunk/parsetexi/extra.c     2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/extra.c     2015-01-15 00:04:47 UTC (rev 6045)
@@ -60,6 +60,20 @@
   e->extra[e->extra_number - 1].type = extra_element_text;
 }
 
+void
+add_extra_key_index_entry (ELEMENT *e, char *key, INDEX_ENTRY *value)
+{
+  add_extra_key (e, key, (ELEMENT *) value);
+  e->extra[e->extra_number - 1].type = extra_index_entry;
+}
+
+void
+add_extra_key_misc_args (ELEMENT *e, char *key, ELEMENT *value)
+{
+  add_extra_key (e, key, value);
+  e->extra[e->extra_number - 1].type = extra_misc_args;
+}
+
 KEY_PAIR *
 lookup_extra_key (ELEMENT *e, char *key)
 {

Modified: trunk/parsetexi/indices.c
===================================================================
--- trunk/parsetexi/indices.c   2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/indices.c   2015-01-15 00:04:47 UTC (rev 6045)
@@ -14,35 +14,115 @@
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>. */
 
-#include "commands.h"
-#include "command_ids.h"
+#include <string.h>
 
-static struct index_name {
-    char *name;
-    char prefix;
-    // int in_code;
-} index_names[] = {
-    "cp", 'c',
-    "fn", 'f',
-    "vr", 'v',
-    "ky", 'k',
-    "pg", 'p',
-    "tp", 't'
+#include "parser.h"
+#include "indices.h"
+
+INDEX index_names[] = {
+  {"cp", "c",},
+  {"fn", "f",},
+  {"vr", "v",},
+  {"ky", "k",},
+  {"pg", "p",},
+  {"tp", "t",},
+  {0, 0},
 };
 
+typedef struct {
+    enum command_id cmd;
+    INDEX *idx;
+} CMD_TO_IDX;
+
+/* Array mapping Texinfo commands to index data structures. */
+static CMD_TO_IDX *cmd_to_idx = 0;
+static size_t num_index_commands = 0;
+static size_t cmd_to_idx_space = 0;
+
+static void
+associate_command_to_index (enum command_id cmd, INDEX *idx)
+{
+  if (num_index_commands == cmd_to_idx_space)
+    {
+      cmd_to_idx = realloc (cmd_to_idx,
+                            sizeof (CMD_TO_IDX) * (cmd_to_idx_space += 10));
+      if (!cmd_to_idx)
+        abort ();
+    }
+
+  cmd_to_idx[num_index_commands].cmd = cmd;
+  cmd_to_idx[num_index_commands++].idx = idx;
+}
+
+/* Get the index associated with CMD. */
+INDEX *
+index_of_command (enum command_id cmd)
+{
+  int i;
+
+  for (i = 0; i < num_index_commands; i++)
+    {
+      if (cmd_to_idx[i].cmd == cmd)
+        return cmd_to_idx[i].idx;
+    }
+  return 0;
+}
+
 void
 init_index_commands (void)
 {
-  struct index_name *i;
+  INDEX *i;
   char name[] = "?index";
-  for (i = index_names;
-       i < &index_names[sizeof(index_names)/sizeof(*index_names)];
-       i++)
+  for (i = index_names; i->name; i++)
     {
       enum command_id new;
-      name[0] = i->prefix;
+      name[0] = *i->prefix;
       new = add_texinfo_command (name);
-      user_defined_command_data[new & ~USER_COMMAND_BIT].flags = CF_misc;
+      user_defined_command_data[new & ~USER_COMMAND_BIT].flags
+        = CF_misc | CF_index_entry_command;
       user_defined_command_data[new & ~USER_COMMAND_BIT].data = MISC_line;
+      associate_command_to_index (new, i);
     }
 }
+
+// 2530
+/* INDEX_AT_COMMAND is the Texinfo @-command defining the index entry.
+   CONTENT is an element whose contents represent the text of the
+   index entry.  CURRENT is the element in the main body of the manual that
+   the index entry refers to. */
+void
+enter_index_entry (enum command_id index_type_command,
+                   enum command_id index_at_command,
+                   ELEMENT *current,
+                   ELEMENT *content /*, content_normalized */ )
+{
+  INDEX *idx;
+  INDEX_ENTRY *entry;
+
+  idx = index_of_command (index_type_command);
+  if (idx->index_number == idx->index_space)
+    {
+      idx->index_entries = realloc (idx->index_entries,
+                             sizeof (INDEX_ENTRY) * (idx->index_space += 20));
+      if (!idx->index_entries)
+        abort ();
+    }
+  entry = &idx->index_entries[idx->index_number++];
+  memset (entry, 0, sizeof (INDEX_ENTRY));
+
+
+  entry->index_name = idx->name;
+  entry->index_at_command = index_at_command;
+  entry->index_type_command = index_type_command;
+  entry->index_prefix = idx->prefix;
+  entry->content = content;
+  //entry->content_normalized = ... ;
+  entry->command = current;
+
+  entry->node = current_node;
+
+  entry->number = idx->index_number;
+
+  add_extra_key_index_entry (current, "index_entry", entry);
+
+}

Added: trunk/parsetexi/indices.h
===================================================================
--- trunk/parsetexi/indices.h                           (rev 0)
+++ trunk/parsetexi/indices.h   2015-01-15 00:04:47 UTC (rev 6045)
@@ -0,0 +1,6 @@
+extern INDEX index_names[];
+
+INDEX *index_of_command (enum command_id cmd);
+void enter_index_entry (enum command_id index_type_command,
+                   enum command_id index_at_command, ELEMENT *current,
+                   ELEMENT *content);

Modified: trunk/parsetexi/main.c
===================================================================
--- trunk/parsetexi/main.c      2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/main.c      2015-01-15 00:04:47 UTC (rev 6045)
@@ -1,4 +1,4 @@
-/* Copyright 2015 Free Software Foundation, Inc.
+/* Copyright 2014, 2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -18,6 +18,7 @@
 
 #include "parser.h"
 #include "input.h"
+#include "indices.h"
 
 int
 main (int argc, char **argv)

Modified: trunk/parsetexi/makeinfo-debug.txt
===================================================================
--- trunk/parsetexi/makeinfo-debug.txt  2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/makeinfo-debug.txt  2015-01-15 00:04:47 UTC (rev 6045)
@@ -8,6 +8,24 @@
 
 ----------- speed comparison-----------------------
 
+Parsing only
+
+time makeinfo -c TEXINFO_OUTPUT_FORMAT=parse texinfo.texi >/dev/null
+real    0m4.687s
+user    0m4.486s
+sys     0m0.054s
+
+Info output:
+time makeinfo texinfo.texi >/dev/null
+
+real    0m13.310s
+user    0m12.393s
+sys     0m0.061s
+
+Parsing is about 1/3 of the total run time.
+texinfo.texi is 835K.
+-
+
 time makeinfo -c TEXINFO_OUTPUT_FORMAT=debugtree texinfo.texi >/dev/null
 
 real    0m5.261s

Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h    2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/parser.h    2015-01-15 00:04:47 UTC (rev 6045)
@@ -30,7 +30,7 @@
 /* In parser.c */
 void push_conditional_stack (enum command_id cond);
 enum command_id pop_conditional_stack (void);
-size_t conditional_number;
+extern size_t conditional_number;
 ELEMENT *parse_texi_file (char *filename);
 int abort_empty_line (ELEMENT **current_inout, char *additional);
 ELEMENT *end_paragraph (ELEMENT *current);
@@ -65,6 +65,8 @@
 void add_extra_key_element (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_key_contents (ELEMENT *e, char *key, ELEMENT *value);
 void add_extra_key_text (ELEMENT *e, char *key, ELEMENT *value);
+void add_extra_key_index_entry (ELEMENT *e, char *key, INDEX_ENTRY *value);
+void add_extra_key_misc_args (ELEMENT *e, char *key, ELEMENT *value);
 KEY_PAIR *lookup_extra_key (ELEMENT *e, char *key);
 
 /* In menus.c */

Added: trunk/parsetexi/test-files/index.texi
===================================================================
--- trunk/parsetexi/test-files/index.texi                               (rev 0)
+++ trunk/parsetexi/test-files/index.texi       2015-01-15 00:04:47 UTC (rev 
6045)
@@ -0,0 +1,35 @@
address@hidden Top
address@hidden Sample
+
+This manual is for Sample
+
address@hidden
+* First Chapter::    The first chapter is the
+                      only chapter in this sample.
+* Index::            Complete index.
address@hidden menu
+
+
address@hidden First Chapter
address@hidden First Chapter
+
+Some index entries:
+
address@hidden One
+One
+
address@hidden Two
+Two
+
address@hidden Three
+Three
+
address@hidden Index
address@hidden Index
+
+
address@hidden cp
+
address@hidden
+
+

Modified: trunk/parsetexi/tree_types.h
===================================================================
--- trunk/parsetexi/tree_types.h        2015-01-14 21:36:21 UTC (rev 6044)
+++ trunk/parsetexi/tree_types.h        2015-01-15 00:04:47 UTC (rev 6045)
@@ -28,6 +28,8 @@
     extra_element,
     extra_element_contents,
     extra_element_text,
+    extra_index_entry,
+    extra_misc_args
 };
 
 typedef struct KEY_PAIR {
@@ -90,3 +92,30 @@
     char *input_file_name;
     char *input_encoding_name;
 } GLOBAL_INFO;
+
+typedef struct {
+    char *index_name;
+    char *index_prefix;
+    enum command_id index_at_command;
+    enum command_id index_type_command;
+
+    /* content->contents is the index entry text */
+    ELEMENT *content;
+    /* content_normalized */
+    ELEMENT *command;
+    ELEMENT *node;
+    int number; /* Index of entry in containing index, 1-based. */
+    enum command_id region;
+} INDEX_ENTRY;
+
+typedef struct {
+    char *name;
+    char *prefix;
+    // int in_code;
+
+    INDEX_ENTRY *index_entries;
+    size_t index_number;
+    size_t index_space;
+} INDEX;
+
+




reply via email to

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