[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6169] parsetexi update
From: |
Gavin D. Smith |
Subject: |
[6169] parsetexi update |
Date: |
Sun, 01 Mar 2015 17:49:32 +0000 |
Revision: 6169
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6169
Author: gavin
Date: 2015-03-01 17:49:30 +0000 (Sun, 01 Mar 2015)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/parsetexi/ChangeLog
trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
trunk/parsetexi/README
trunk/parsetexi/api.c
trunk/parsetexi/dump_perl.c
trunk/parsetexi/end_line.c
trunk/parsetexi/handle_commands.c
trunk/parsetexi/indices.c
trunk/parsetexi/indices.h
trunk/parsetexi/macro.c
trunk/parsetexi/parser.c
trunk/parsetexi/separator.c
Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/ChangeLog 2015-03-01 17:49:30 UTC (rev 6169)
@@ -1,3 +1,11 @@
+2015-03-01 Gavin Smith <address@hidden>
+
+ * end_line.c (parse_line_commanad_args) <CM_defindex>: Call
+ add_index.
+ * handle_commands.c (handle_misc_command) <CM_node>: Set
+ remaining_args on element.
+ * api.c (element_to_perl_hash): Output 'line_nr'.
+
2015-02-27 Gavin Smith <address@hidden>
* tree_types.h (enum extra_type): Add extra_deleted.
Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm 2015-03-01 00:06:37 UTC (rev
6168)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm 2015-03-01 17:49:30 UTC (rev
6169)
@@ -250,7 +250,6 @@
$LABELS = build_label_list ();
- # TODO: Get $INDEX_NAMES as well
$INDEX_NAMES = build_index_data ();
} elsif (0) {
Modified: trunk/parsetexi/README
===================================================================
--- trunk/parsetexi/README 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/README 2015-03-01 17:49:30 UTC (rev 6169)
@@ -6,6 +6,7 @@
changed to use the module in the Parsetexi subdirectory instead of
Texinfo::Parser.
+=====================================================================
Notes -
How to debug with valgrind -
export PERL5LIB to the value in the makeinfo script
@@ -18,4 +19,14 @@
valgrind --vgdb-error=0 perl texi2any-C.pl texinfo.texi
+=====================================================================
+Can compare execution runs of parsetexi and Perl makeinfo with
+
+makeinfo -C DEBUG=1 node_structure.texi |& less
+
+vs.
+
+./parsetexi node_structure.texi |& less
+
+
Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/api.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -340,7 +340,28 @@
#undef STORE
}
- /* TODO: line_nr. */
+ if (e->line_nr.line_nr)
+ {
+#define STORE(key, sv) hv_store (hv, key, strlen (key), sv, 0)
+ LINE_NR *line_nr = &e->line_nr;
+ HV *hv = newHV ();
+ hv_store (e->hv, "line_nr", strlen ("line_nr"),
+ newRV_inc((SV *)hv), 0);
+
+ if (line_nr->file_name)
+ {
+ STORE("file_name", newSVpv (line_nr->file_name, 0));
+ }
+
+ if (line_nr->line_nr)
+ {
+ STORE("line_nr", newSViv (line_nr->line_nr));
+ }
+
+ /* TODO: macro. */
+ STORE("macro", newSVpv ("", 0));
+#undef STORE
+ }
}
HV *
@@ -467,17 +488,17 @@
build_index_data (void)
{
HV *hv;
- INDEX *i;
+ INDEX **i, *idx;
dTHX;
hv = newHV ();
- for (i = index_names; i->name; i++)
+ for (i = index_names; (idx = *i); i++)
{
HV *hv2;
- hv2 = build_single_index_data (i);
- hv_store (hv, i->name, strlen (i->name), newRV_inc ((SV *)hv2), 0);
+ hv2 = build_single_index_data (idx);
+ hv_store (hv, idx->name, strlen (idx->name), newRV_inc ((SV *)hv2), 0);
}
return hv;
Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/dump_perl.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -566,24 +566,24 @@
static void
dump_indices_information (void)
{
- INDEX *i;
+ INDEX **i, *idx;
text_append (&indices_dump, "\n$INDEX_NAMES = {\n");
- for (i = index_names; i->name; i++)
+ for (i = index_names; (idx = *i); i++)
{
- text_printf (&indices_dump, "'%s' => {", i->name);
- text_printf (&indices_dump, "'name' => '%s',", i->name);
+ text_printf (&indices_dump, "'%s' => {", idx->name);
+ text_printf (&indices_dump, "'name' => '%s',", idx->name);
text_printf (&indices_dump, "'in_code' => 0,");
/* TODO: This is a list of recognized prefixes for the index. */
text_printf (&indices_dump, "'prefix' => ['%c', '%s'],",
- *i->name, i->name);
+ *idx->name, idx->name);
/* TODO: Handle index merging. */
text_printf (&indices_dump, "'contained_indices' => {'%s'=>1},",
- i->name);
+ idx->name);
- dump_entries_of_index (i);
+ dump_entries_of_index (idx);
text_printf (&indices_dump, "},\n");
}
Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/end_line.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -157,7 +157,7 @@
ELEMENT *line_args;
ELEMENT *arg = line_command->args.list[0];
ELEMENT *argarg = 0;
- enum command_id command = line_command->cmd;
+ enum command_id cmd;
char *line;
int i;
@@ -196,10 +196,10 @@
if (argarg->text.end == 0)
abort ();
- command = line_command->cmd;
+ cmd = line_command->cmd;
line = argarg->text.text;
- switch (command)
+ switch (cmd)
{
case CM_alias:
{
@@ -343,7 +343,7 @@
/* Disallow index names NAME where it is likely that for
a source file BASE.texi, there will be other files called
BASE.NAME in the same directory. This is to prevent such
- files being overwritten by the files produced by texindex. */
+ files being overwritten by the files read by texindex. */
{
/* TODO: Also forbid existing index names. */
static char *forbidden_index_names[] = {
@@ -358,11 +358,13 @@
}
ADD_ARG (name);
- /* TODO: Store the index. */
+
+ add_index (name, cmd == CM_defcodeindex ? 1 : 0);
+
break;
defindex_invalid:
line_errorf ("bad argument to @%s: %s",
- command_data(command).cmdname, line);
+ command_data(cmd).cmdname, line);
break;
defindex_reserved:
line_errorf ("reserved index name %s", name);
@@ -396,7 +398,7 @@
break;
synindex_invalid:
line_errorf ("bad argument to @%s: %s",
- command_data(command).cmdname, line);
+ command_data(cmd).cmdname, line);
free (from); free (to);
break;
}
@@ -419,7 +421,7 @@
}
else
line_errorf ("@%s argument must be `top' or `bottom', not `%s'",
- command_data(command).cmdname, line);
+ command_data(cmd).cmdname, line);
break;
}
@@ -940,11 +942,11 @@
nodes_manuals = malloc (sizeof (NODE_SPEC_EXTRA *) * 2);
nodes_manuals[1] = 0;
+ // TODO: Add the other args to @node as well, if they were given
first_arg = current->args.list[0];
nodes_manuals[0] = parse_node_manual (first_arg);
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)". */
Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/handle_commands.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -42,20 +42,20 @@
/* Line 4289 */
ELEMENT *
handle_misc_command (ELEMENT *current, char **line_inout,
- enum command_id cmd_id)
+ enum command_id cmd)
{
ELEMENT *misc = 0;
char *line = *line_inout;
int arg_spec;
/* Root commands (like @node) and @bye 4290 */
- if (command_data(cmd_id).flags & CF_root || cmd_id == CM_bye)
+ if (command_data(cmd).flags & CF_root || cmd == CM_bye)
{
ELEMENT *closed_elt; /* Not used */
- current = close_commands (current, 0, &closed_elt, cmd_id);
+ current = close_commands (current, 0, &closed_elt, cmd);
if (current->type == ET_text_root)
{
- if (cmd_id != CM_bye)
+ if (cmd != CM_bye)
{
/* Something to do with document_root and text_root. */
ELEMENT *new_root = new_element (ET_document_root);
@@ -73,13 +73,13 @@
/* Look up information about this command ( noarg skipline skipspace text
line lineraw /^\d$/). */
- arg_spec = command_data(cmd_id).data;
+ arg_spec = command_data(cmd).data;
/* noarg */
if (arg_spec == MISC_noarg)
{
/*
- if (close_preformatted_command(cmd_id))
+ if (close_preformatted_command(cmd))
current = begin_preformatted (current);
*/
}
@@ -95,7 +95,7 @@
of the line if necessary. */
misc = new_element (ET_NONE);
- misc->cmd = cmd_id;
+ misc->cmd = cmd;
if (arg_spec == MISC_skipline || arg_spec == MISC_lineraw)
{
@@ -107,11 +107,11 @@
}
else /* arg_spec == MISC_special */
{
- args = parse_special_misc_command (line, cmd_id); //4362
+ args = parse_special_misc_command (line, cmd); //4362
add_extra_string (misc, "arg_line", strdup (line));
}
- if ((cmd_id == CM_set || cmd_id == CM_clear)
+ if ((cmd == CM_set || cmd == CM_clear)
&& 0 )
{
/* TODO: Handle @set txicodequoteundirected as an
@@ -148,32 +148,34 @@
// 4429 TODO @bye
- if (close_preformatted_command(cmd_id))
+ if (close_preformatted_command(cmd))
current = begin_preformatted (current);
line += strlen (line); /* FIXME: Where does the control flow go? */
}
- else /* line 4435 - text, line, skipspace or a number */
+ else
{
+ /* line 4435 - text, line, skipspace or a number.
+ (This includes handling of "@end", which is MISC_text.) */
+
int line_arg = 0;
if (arg_spec != MISC_skipspace)
line_arg = 1;
- /* @END IS SOMEWHERE IN HERE ('text') */
/* 4439 */
/* Special handling of @item because it can appear
in several contents: in an @itemize, a @table, or
a @multitable. */
- if (cmd_id == CM_item || cmd_id == CM_itemx
- || cmd_id == CM_headitem || cmd_id == CM_tab)
+ if (cmd == CM_item || cmd == CM_itemx
+ || cmd == CM_headitem || cmd == CM_tab)
{
ELEMENT *parent;
// itemize or enumerate 4443
if ((parent = item_container_parent (current)))
{
- if (cmd_id == CM_item)
+ if (cmd == CM_item)
{
ELEMENT *misc;
debug ("ITEM CONTAINER");
@@ -197,7 +199,7 @@
// *table
else if ((parent = item_line_parent (current)))
{
- if (cmd_id == CM_item || cmd_id == CM_itemx)
+ if (cmd == CM_item || cmd == CM_itemx)
{
ELEMENT *misc;
@@ -205,7 +207,7 @@
current = parent;
// gather_previous_item ();
misc = new_element (ET_NONE);
- misc->cmd = cmd_id;
+ misc->cmd = cmd;
add_to_element_contents (current, misc);
line_arg = 1;
}
@@ -213,8 +215,8 @@
// multitable
else if ((parent = item_multitable_parent (current))) // 4477
{
- if (cmd_id != CM_item && cmd_id != CM_headitem
- && cmd_id != CM_tab)
+ if (cmd != CM_item && cmd != CM_headitem
+ && cmd != CM_tab)
{
/* 4521 error - not meaningful */
abort ();
@@ -225,7 +227,7 @@
/* if
{
}
- else */ if (cmd_id == CM_tab)
+ else */ if (cmd == CM_tab)
{ // 4484
ELEMENT *row;
@@ -237,7 +239,7 @@
{
ELEMENT *misc;
misc = new_element (ET_NONE);
- misc->cmd = cmd_id;
+ misc->cmd = cmd;
add_to_element_contents (row, misc);
current = misc;
debug ("TAB");
@@ -254,7 +256,7 @@
row = new_element (ET_row);
add_to_element_contents (parent, row);
misc = new_element (ET_NONE);
- misc->cmd = cmd_id;
+ misc->cmd = cmd;
add_to_element_contents (row, misc);
current = misc;
@@ -262,7 +264,7 @@
}
}
} /* item_multitable_parent */
- else if (cmd_id == CM_tab) // 4526
+ else if (cmd == CM_tab) // 4526
{
// error - tab outside of multitable
current = begin_preformatted (current);
@@ -279,7 +281,7 @@
{
/* Add to contents */
misc = new_element (ET_NONE);
- misc->cmd = cmd_id;
+ misc->cmd = cmd;
misc->line_nr = line_nr;
add_to_element_contents (current, misc);
@@ -289,7 +291,7 @@
}
/* 4546 - def*x */
- if (command_data(cmd_id).flags & CF_def)
+ if (command_data(cmd).flags & CF_def)
{
enum command_id base_command;
char *base_name;
@@ -297,7 +299,7 @@
/* Find the command with "x" stripped from the end, e.g.
deffnx -> deffn. */
- base_name = strdup (command_data(cmd_id).cmdname);
+ base_name = strdup (command_data(cmd).cmdname);
base_len = strlen (base_name);
if (base_name[base_len - 1] != 'x')
abort ();
@@ -313,14 +315,14 @@
if (current->cmd == base_command)
{
// Does this gather an "inter_def_item" ?
- // gather_def_item (current, cmd_id);
+ // gather_def_item (current, cmd);
}
else
{
// error - deffnx not after deffn
line_errorf ("must be after @%s to use @%s",
command_data(base_command).cmdname,
- command_data(cmd_id).cmdname);
+ command_data(cmd).cmdname);
}
}
} /* 4571 */
@@ -336,9 +338,17 @@
add_to_element_args (current, arg);
/* 4584 - node */
+ if (cmd == CM_node)
+ {
+ /* At most three comma-separated arguments to @node. This
+ is the only (non-block) line command taking comma-separated
+ arguments. Its arguments will be gathered the same as
+ those of some block line commands and brace commands. */
+ current->remaining_args = 3;
+ }
/* 4586 - author */
/* 4612 - dircategory */
- if (cmd_id == CM_dircategory && current_node)
+ if (cmd == CM_dircategory && current_node)
{
/* warning - @dircategory after first node. */
abort ();
@@ -349,7 +359,7 @@
/* add 'line' to context_stack (Parser.pm:141). This will be the
case while we read the argument on this line. */
- if (!(command_data(cmd_id).flags & CF_def))
+ if (!(command_data(cmd).flags & CF_def))
push_context (ct_line);
}
start_empty_line_after_command (current, &line); //4621
Modified: trunk/parsetexi/indices.c
===================================================================
--- trunk/parsetexi/indices.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/indices.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -15,19 +15,14 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <string.h>
+#include <stdio.h>
#include "parser.h"
#include "indices.h"
-INDEX index_names[] = {
- {"cp", "c",},
- {"fn", "f",},
- {"vr", "v",},
- {"ky", "k",},
- {"pg", "p",},
- {"tp", "t",},
- {0, 0},
-};
+INDEX **index_names;
+int number_of_indices;
+int space_for_indices;
typedef struct {
enum command_id cmd;
@@ -69,22 +64,74 @@
}
void
+add_index_command (char *cmdname, INDEX *idx)
+{
+ enum command_id new = add_texinfo_command (cmdname);
+ 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, idx);
+}
+
+static INDEX *
+add_index_internal (char *name, int in_code)
+{
+ INDEX *idx = malloc (sizeof (INDEX));
+ char *cmdname;
+
+ memset (idx, 0, sizeof *idx);
+ idx->name = name;
+ idx->prefix = name;
+ if (number_of_indices == space_for_indices)
+ {
+ space_for_indices += 5;
+ index_names = realloc (index_names, (space_for_indices + 1)
+ * sizeof (INDEX *));
+ }
+ index_names[number_of_indices++] = idx;
+ index_names[number_of_indices] = 0;
+
+ /* For example, "rq" -> "rqindex". */
+ asprintf (&cmdname, "%s%s", name, "index");
+ add_index_command (cmdname, idx);
+ free (cmdname);
+ return idx;
+}
+
+void
+add_index (char *name, int in_code)
+{
+ INDEX *idx;
+
+ idx = add_index_internal (name, in_code);
+}
+
+void
init_index_commands (void)
{
- INDEX *i;
+ INDEX *idx;
+ char **p;
+ char *default_indices[] = {
+ "cp",
+ "fn",
+ "vr",
+ "ky",
+ "pg",
+ "tp",
+ 0,
+ };
char name[] = "?index";
- for (i = index_names; i->name; i++)
+
+ for (p = default_indices; *p; p++)
{
- enum command_id new;
- name[0] = *i->prefix;
- new = add_texinfo_command (name);
- 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);
+ /* Both @cpindex and @cindex are added. */
+ idx = add_index_internal (*p, 0);
+ *name = **p;
+ add_index_command (name, idx);
}
}
+
// 2530
/* INDEX_AT_COMMAND is the Texinfo @-command defining the index entry.
CONTENT is an element whose contents represent the text of the
Modified: trunk/parsetexi/indices.h
===================================================================
--- trunk/parsetexi/indices.h 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/indices.h 2015-03-01 17:49:30 UTC (rev 6169)
@@ -1,5 +1,6 @@
-extern INDEX index_names[];
+extern INDEX **index_names;
+void add_index (char *name, int in_code);
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,
Modified: trunk/parsetexi/macro.c
===================================================================
--- trunk/parsetexi/macro.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/macro.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -235,6 +235,7 @@
break;
case '{':
braces_level++;
+ text_append_n (&arg, sep, 1);
pline = sep + 1;
break;
case '}':
Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/parser.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -984,7 +984,6 @@
}
else if (command_data(cmd).flags & CF_brace) /* line 4835 */
- /* or definfoenclose */
{
current = handle_brace_command (current, &line, cmd);
}
Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-03-01 00:06:37 UTC (rev 6168)
+++ trunk/parsetexi/separator.c 2015-03-01 17:49:30 UTC (rev 6169)
@@ -316,10 +316,20 @@
register_command_arg (current, "brace_command_contents");
//remove_empty_content_arguments ();
}
+ else
+ {
+ isolate_last_space (current, 0);
+ if (command_flags(current->parent) & CF_block)
+ {
+ register_command_arg (current, "block_command_line_contents");
+ }
+ }
type = current->type;
current = current->parent;
+
#if 0
+ /* TODO 5244 */
if (current is an inline command (like inlineraw) all brace commands))
{
}
@@ -359,7 +369,7 @@
else if (separator == ',' && current->type == ET_misc_line_arg
&& current->parent->cmd == CM_node) // 5297
{
- // Warning - superfluous arguments for node
+ line_warn ("superfluous arguments for node");
}
/* 5303 After a separator in a menu. */
else if ((separator == ','
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6169] parsetexi update,
Gavin D. Smith <=