[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6193] parsetexi def line
From: |
Gavin D. Smith |
Subject: |
[6193] parsetexi def line |
Date: |
Mon, 23 Mar 2015 14:24:52 +0000 |
Revision: 6193
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6193
Author: gavin
Date: 2015-03-23 14:24:49 +0000 (Mon, 23 Mar 2015)
Log Message:
-----------
parsetexi def line
Modified Paths:
--------------
trunk/parsetexi/ChangeLog
trunk/parsetexi/TODO
trunk/parsetexi/api.c
trunk/parsetexi/command_data.txt
trunk/parsetexi/commands.h
trunk/parsetexi/def.c
trunk/parsetexi/def.h
trunk/parsetexi/dump_perl.c
trunk/parsetexi/end_line.c
trunk/parsetexi/extra.c
trunk/parsetexi/handle_commands.c
trunk/parsetexi/parser.h
trunk/parsetexi/tree_types.h
Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/ChangeLog 2015-03-23 14:24:49 UTC (rev 6193)
@@ -1,3 +1,14 @@
+2015-03-23 Gavin Smith <address@hidden>
+
+ * tree_types.h (enum extra_type): Add extra_def_args.
+ (DEF_ARGS_EXTRA): New type.
+ * api.c (element_to_perl_hash),
+ * dump_perl.c (dump_extra): Handle extra_def_args.
+ * def.c (parse_def, next_bracketed_or_word): First
+ implementations.
+ * end_line.c <ET_def_line>: Call parse_def. Don't record the
+ index entry yet.
+
2015-03-14 Gavin Smith <address@hidden>
* close.c (close_command_cleanup): @multitable handling.
Modified: trunk/parsetexi/TODO
===================================================================
--- trunk/parsetexi/TODO 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/TODO 2015-03-23 14:24:49 UTC (rev 6193)
@@ -1,4 +1,5 @@
* conditionals on @set/@value, output format
+* implement command_warn properly
* Check everywhere we store values, we check properly what to do if the
values are already defined.
* check valid nestings
Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/api.c 2015-03-23 14:24:49 UTC (rev 6193)
@@ -332,6 +332,56 @@
be much nicer if we could get rid of the need for this key. */
/* Could we set this afterwards in build_index_data? */
break;
+ case extra_def_args:
+ {
+ /* Value is an array of two-element arrays. */
+ AV *av, *av2;
+ HV *def_parsed_hash;
+ char *label;
+ int j;
+ DEF_ARGS_EXTRA *d = (DEF_ARGS_EXTRA *) f;
+
+ av = newAV ();
+ STORE(newRV_inc ((SV *)av));
+
+ /* Also create a "def_parsed_hash" extra value. The key name
+ for this is hard-coded here. */
+ def_parsed_hash = newHV ();
+ hv_store (extra, "def_parsed_hash",
+ strlen ("def_parsed_hash"),
+ newRV_inc ((SV *)def_parsed_hash), 0);
+
+ for (j = 0; (label = d->labels[j]); j++)
+ {
+ ELEMENT *elt = d->elements[j];
+ av2 = newAV ();
+ av_push (av, newRV_inc ((SV *)av2));
+ av_push (av2, newSVpv (label, 0));
+ if (!elt->hv)
+ {
+ /* TODO: Same problem as "extra_element" cross-tree
+ references. */
+ if (elt->parent_type != route_not_in_tree)
+ abort ();
+ element_to_perl_hash (elt);
+ }
+ if (!elt->hv)
+ abort ();
+ av_push (av2, newRV_inc ((SV *)elt->hv));
+
+ /* Set keys of "def_parsed_hash". */
+ // 2793
+ if (strcmp (label, "spaces")
+ && strcmp (label, "arg") && strcmp (label, "typearg")
+ && strcmp (label, "delimiter"))
+ {
+ hv_store (def_parsed_hash, label, strlen (label),
+ newRV_inc ((SV *)elt->hv), 0);
+ }
+ }
+
+ break;
+ }
default:
abort ();
break;
Modified: trunk/parsetexi/command_data.txt
===================================================================
--- trunk/parsetexi/command_data.txt 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/command_data.txt 2015-03-23 14:24:49 UTC (rev 6193)
@@ -360,17 +360,17 @@
defop block,def
deftp block,def
# shortcuts
-defun block,def
-defmac block,def
-defspec block,def
-defvar block,def
-defopt block,def
-deftypefun block,def
-deftypevar block,def
-defivar block,def
-deftypeivar block,def
-defmethod block,def
-deftypemethod block,def
+defun block,def,def_alias
+defmac block,def,def_alias
+defspec block,def,def_alias
+defvar block,def,def_alias
+defopt block,def,def_alias
+deftypefun block,def,def_alias
+deftypevar block,def,def_alias
+defivar block,def,def_alias
+deftypeivar block,def,def_alias
+defmethod block,def,def_alias
+deftypemethod block,def,def_alias
# def*x
deffnx misc,def
@@ -383,17 +383,17 @@
defopx misc,def
deftpx misc,def
# shortcuts
-defunx misc,def
-defmacx misc,def
-defspecx misc,def
-defvarx misc,def
-defoptx misc,def
-deftypefunx misc,def
-deftypevarx misc,def
-defivarx misc,def
-deftypeivarx misc,def
-defmethodx misc,def
-deftypemethodx misc,def
+defunx misc,def,def_alias
+defmacx misc,def,def_alias
+defspecx misc,def,def_alias
+defvarx misc,def,def_alias
+defoptx misc,def,def_alias
+deftypefunx misc,def,def_alias
+deftypevarx misc,def,def_alias
+defivarx misc,def,def_alias
+deftypeivarx misc,def,def_alias
+defmethodx misc,def,def_alias
+deftypemethodx misc,def,def_alias
# 760
multitable block,blockitem BLOCK_multitable
Modified: trunk/parsetexi/commands.h
===================================================================
--- trunk/parsetexi/commands.h 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/commands.h 2015-03-23 14:24:49 UTC (rev 6193)
@@ -41,7 +41,7 @@
/* In indices.c */
void init_index_commands (void);
-/* Available command flags. Based on tp/Texinfo/Common.tp. */
+/* Available command flags. Based on tp/Texinfo/Common.pm. */
#define CF_misc 0x0001
#define CF_default_index 0x0002
@@ -62,7 +62,7 @@
#define CF_format_raw 0x8000
// #define free 0x00010000
#define CF_def 0x00020000
-#define CF_def_aliases 0x00040000
+#define CF_def_alias 0x00040000
#define CF_menu 0x00080000
#define CF_align 0x00100000
#define CF_region 0x00200000
Modified: trunk/parsetexi/def.c
===================================================================
--- trunk/parsetexi/def.c 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/def.c 2015-03-23 14:24:49 UTC (rev 6193)
@@ -14,7 +14,10 @@
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 <string.h>
+
#include "parser.h"
+#include "text.h"
// 1471
void
@@ -57,109 +60,339 @@
else
destroy_element (def_item);
}
+
-#if 0
-/* *SPACES is set to... */
static void
-next_bracketed_or_word (char **spaces)
+shallow_destroy_element (ELEMENT *e)
{
- /* Change ET_bracketed to ET_bracketed_def_content. */
+ free (e->text.text);
+ free (e);
}
-enum arg_type { end, category, name, arg, type, argtype, class };
+// 2335
+/* Used for definition line parsing. Return next unit on the line after
+ a definition command like @deffn. The contents of E is what is remaining
+ in the argument line. *SPACES_OUT is set to an element with spaces before
+ the line. */
+static ELEMENT *
+next_bracketed_or_word (ELEMENT *e, ELEMENT **spaces_out)
+{
+ char *text;
+ ELEMENT *spaces = 0;
+ int space_len;
+ *spaces_out = 0;
+ if (e->contents.number == 0)
+ return 0; /* No more arguments */
+
+ text = e->contents.list[0]->text.text;
+ if (text)
+ {
+ space_len = strspn (text, whitespace_chars);
+ if (text[space_len] == '\0')
+ {
+ /* Text is completely spaces. */
+ spaces = remove_from_contents (e, 0); // 2341
+ if (spaces->parent_type != route_not_in_tree)
+ abort ();
+ //spaces->type = ET_spaces; // TODO: No such element type.
+
+ /* Remove a trailing newline. */
+ if (spaces->text.end > 0
+ && spaces->text.text[spaces->text.end - 1] == '\n')
+ {
+ spaces->text.text[--spaces->text.end] = '\0';
+ }
+
+ if (spaces->text.end > 0)
+ *spaces_out = spaces;
+ else
+ shallow_destroy_element (spaces);
+ }
+ }
+
+ if (e->contents.number == 0)
+ return 0; /* No more arguments */
+
+ if (e->contents.list[0]->type == ET_bracketed)
+ {
+ ELEMENT *bracketed = remove_from_contents (e, 0);
+ ELEMENT *returned = new_element (ET_bracketed_def_content);
+
+ // isolate_last_space (bracketed, ET_empty_space_at_end_def_bracketed);
+
+ /* TODO: Why do we need the parent ? */
+ //returned->parent = bracketed->parent;
+ returned->contents = bracketed->contents;
+ returned->parent_type = route_not_in_tree;
+
+ return returned;
+ }
+ else if (e->contents.list[0]->cmd != CM_NONE) // 2363
+ {
+ return remove_from_contents (e, 0);
+ }
+ else
+ {
+ /* Extract span of whitespace characters followed by a span of
+ non-whitespace characters. */
+ ELEMENT *f = e->contents.list[0];
+ ELEMENT *returned = new_element (ET_NONE);
+ int arg_len;
+ text = f->text.text;
+ space_len = strspn (text, whitespace_chars);
+ if (space_len > 0)
+ {
+ //spaces = new_element (ET_spaces);
+ spaces = new_element (ET_NONE);
+ spaces->parent_type = route_not_in_tree;
+ text_append_n (&spaces->text, text, space_len);
+ text += space_len;
+ *spaces_out = spaces;
+ }
+ arg_len = strcspn (text, whitespace_chars);
+ text_append_n (&returned->text, text, arg_len);
+
+ memmove (f->text.text, f->text.text + space_len + arg_len,
+ f->text.end - (space_len + arg_len) + 1);
+ f->text.end -= space_len + arg_len;
+ if (f->text.end == 0)
+ shallow_destroy_element (remove_from_contents (e, 0));
+
+ returned->parent_type = route_not_in_tree;
+ return returned;
+ }
+}
+
typedef struct {
enum command_id alias;
enum command_id command;
- char *index_name;
+ char *category;
} DEF_ALIAS;
-DEF_MAP def_aliases[];
+DEF_ALIAS def_aliases[] = {
+ CM_defun, CM_deffn, "Function",
+ CM_defmac, CM_deffn, "Macro",
+ CM_defspec, CM_deffn, "Special Form",
+ CM_defvar, CM_defvr, "Variable",
+ CM_defopt, CM_defvr, "User Option",
+ CM_deftypefun, CM_deftypefn, "Function",
+ CM_deftypevar, CM_deftypevr, "Variable",
+ CM_defivar, CM_defcv, "Instance Variable",
+ CM_deftypeivar, CM_deftypecv, "Instance Variable",
+ CM_defmethod, CM_defop, "Method",
+ CM_deftypemethod, CM_deftypeop, "Method",
+ 0, 0, 0
};
+/* Note that ARG should not be an element in the main tree. */
+static void
+add_to_def_args_extra (DEF_ARGS_EXTRA *d, char *label, ELEMENT *arg)
+{
+ if (d->nelements >= d->space - 1)
+ {
+ d->space += 5;
+ d->labels = realloc (d->labels, d->space * sizeof (char *));
+ d->elements = realloc (d->elements, d->space * sizeof (ELEMENT *));
+ }
+ if (arg && arg->hv)
+ abort ();
+ if (!arg)
+ return; /* Probably a bug */
+
+ if (arg->parent_type != route_not_in_tree)
+ abort ();
+
+ d->labels[d->nelements] = label;
+ d->elements[d->nelements++] = arg;
+ d->labels[d->nelements] = 0;
+ d->elements[d->nelements] = 0;
+}
+
/* Parse the arguments on a def* command line. */
-/* Note that this does more than the Perl version. */
// 2378
-char **
+DEF_ARGS_EXTRA *
parse_def (enum command_id command, ELEMENT_LIST contents)
{
- char *category;
+ /* The return value - suitable for "def_args" extra value. */
+ DEF_ARGS_EXTRA *def_args;
+ int i;
+
+ ELEMENT *arg_line; /* Copy of argument line. */
+ ELEMENT *arg, *spaces; /* Arguments and spaces extracted from line. */
+ ELEMENT *e;
+
enum command_id original_command = CM_NONE;
- /* Check for "def alias" - for example defun for deffn
- 'defun', {'deffn' => gdt('Function')},
+ def_args = malloc (sizeof (DEF_ARGS_EXTRA));
+ memset (def_args, 0, sizeof (DEF_ARGS_EXTRA));
- Overwrite command with deffn.
+ /* Copy contents of argument line. */
+ arg_line = new_element (ET_NONE);
+ for (i = 0; i < contents.number; i++)
+ {
+ ELEMENT *copy = malloc (sizeof (ELEMENT));
+ *copy = *contents.list[i];
+ text_init (©->text);
+ text_append_n (©->text,
+ contents.list[i]->text.text,
+ contents.list[i]->text.end);
+ add_to_element_contents (arg_line, copy);
+ copy->parent_type = route_not_in_tree;
- Prepended content is stuck into contents, so
- defun is converted into
- deffn Function
- */
- if (command_data(command).flags & CF_def_alias)
+ /* Note that these copied elements should be destroyed with
+ shallow_destroy_element, not destroy_element, because their
+ contents and args are shared with in-tree elements. */
+ }
+
+ if (arg_line->contents.number > 0 // 2385
+ && arg_line->contents.list[0]->type == ET_empty_spaces_after_command)
{
+ shallow_destroy_element (remove_from_contents (arg_line, 0));
+ }
+
+ /* Check for "def alias" - for example @defun for @deffn. */
+ if (command_data(command).flags & CF_def_alias) // 2387
+ {
+ char *category;
int i;
for (i = 0; i < sizeof (def_aliases) / sizeof (*def_aliases); i++)
{
if (def_aliases[i].alias == command)
goto found;
}
- abort ();
+ abort (); /* Has CF_def_alias but no alias defined. */
found:
- category = def_aliases[i].index_name;
+ category = def_aliases[i].category;
original_command = command;
command = def_aliases[i].command;
- /* Perl does something with gettext here, so category is not just
- a string, but also a Texinfo tree. Why? */
- }
+ /* TODO: Get the gettext translation of "Function" etc. The result of
+ this is actually a general Texinfo tree, instead of just a string. */
+ /* tree = gdt (category); */
-
- // @args is def_map
- // $arg_type - set if there are supposed to be arguments
+ /* Overwrite command with @deffn.
- /* Read arguments as [CATEGORY] [CLASS] [TYPE] NAME [ARGUMENTS] */
+ Prepended content is stuck into contents, so
+ @defun is converted into
+ @deffn Function */
- if (!category)
- {
- /* Next arg is the category. */
+ e = new_element (ET_NONE);
+ text_append (&e->text, category);
+ insert_into_contents (arg_line, e, 0);
+ e->parent_type = route_not_in_tree;
+
+ e = new_element (ET_NONE);
+ text_append_n (&e->text, " ", 1);
+ insert_into_contents (arg_line, e, 1);
+ e->parent_type = route_not_in_tree;
}
+ // 2418 - copy text in contents
+
+ /* Read arguments as CATEGORY [CLASS] [TYPE] NAME [ARGUMENTS].
+
+ Meaning of these:
+ CATEGORY - type of entity, e.g. "Function"
+ CLASS - class for object-oriented programming
+ TYPE - data type of a variable or function return value
+ NAME - name of entity being documented
+ ARGUMENTS - arguments to a function or macro */
+
+ /* CATEGORY */
+ arg = next_bracketed_or_word (arg_line, &spaces);
+ if (spaces)
+ add_to_def_args_extra (def_args, "spaces", spaces);
+ add_to_def_args_extra (def_args, "category", arg);
+
+ /* CLASS */
if (command == CM_deftypeop
|| command == CM_defcv
|| command == CM_deftypecv
- || command == CM_op)
- /* Next arg is the class. */
+ || command == CM_defop)
{
- next_bracketed_or_word ();
+ arg = next_bracketed_or_word (arg_line, &spaces);
+ if (spaces)
+ add_to_def_args_extra (def_args, "spaces", spaces);
+ add_to_def_args_extra (def_args, "class", arg);
}
+ /* TYPE */
if (command == CM_deftypefn
|| command == CM_deftypeop
|| command == CM_deftypevr
|| command == CM_deftypecv)
- /* Next arg is the type. */
{
- next_bracketed_or_word ();
+ arg = next_bracketed_or_word (arg_line, &spaces);
+ if (spaces)
+ add_to_def_args_extra (def_args, "spaces", spaces);
+ add_to_def_args_extra (def_args, "type", arg);
}
+ /* NAME */
/* All command types get a name. */
- name = next_bracketed_or_word ();
+ arg = next_bracketed_or_word (arg_line, &spaces);
+ if (spaces)
+ add_to_def_args_extra (def_args, "spaces", spaces);
+ add_to_def_args_extra (def_args, "name", arg);
- // ...
+ /* ARGUMENTS */
+ // 2441
+ while (arg_line->contents.number > 0)
+ {
+ arg = next_bracketed_or_word (arg_line, &spaces);
+ if (spaces)
+ add_to_def_args_extra (def_args, "spaces", spaces);
+ if (!arg)
+ break;
+ if (arg->text.end > 0) // 2445
+ {
+ ELEMENT *e;
+ char *p = arg->text.text;
+ int len;
+ /* Split this argument into multiple arguments, separated by
+ separator characters. */
+ while (1)
+ {
+ /* Square and round brackets used for optional arguments
+ and grouping. Commas allowed as well? */
+ len = strcspn (p, "[](),");
+ if (len > 0)
+ {
+ e = new_element (ET_NONE);
+ e->parent_type = route_not_in_tree;
+ text_append_n (&e->text, p, len);
+ add_to_def_args_extra (def_args, "arg", e);
+ p += len;
+ }
+ len = strspn (p, "[](),");
+ if (len == 0)
+ break;
+ e = new_element (ET_NONE);
+ e->parent_type = route_not_in_tree;
+ // e = new_element (ET_delimiter); //TODO : No such type
+ text_append_n (&e->text, p, len);
+ add_to_def_args_extra (def_args, "delimiter", e);
+ p += len;
+ }
+ }
+ }
- /* @result is an array of pairs, left being the type of argument (e.g.
- 'class', right being the argument given. */
- /* @args_results are the arguments at the end I suppose. Left side of
- elements are either 'arg' or 'delimeter'. */
+ // 2460 - argtype
+ /* TODO: Change some of the left sides to 'typearg'.
+ What's the difference between this and type? */
+ if (command == CM_deftypefn || command == CM_deftypeop
+ || command == CM_deftp)
+ {
+ }
- /* For 'argtype', change some of the left sides to 'typearg'. */
+ destroy_element (arg_line);
+ return def_args;
- /* @args and @args_results are concatenated and returned. */
-
-
+#if 0
// In calling code at 2788, this array is saved in the extra key.
// 2853 an index entry is also entered
@@ -167,6 +400,6 @@
/* , index_entry_normalized */ );
/* Notes: See 2812 for value of 'name'. */
+#endif
}
-#endif
Modified: trunk/parsetexi/def.h
===================================================================
--- trunk/parsetexi/def.h 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/def.h 2015-03-23 14:24:49 UTC (rev 6193)
@@ -1 +1,2 @@
void gather_def_item (ELEMENT *current /* , enum command_id next_command */ );
+DEF_ARGS_EXTRA *parse_def (enum command_id command, ELEMENT_LIST contents);
Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/dump_perl.c 2015-03-23 14:24:49 UTC (rev 6193)
@@ -311,6 +311,30 @@
dump_string (value, text);
text_append_n (text, "',\n", 3);
}
+ else if (e->extra[i].type == extra_def_args)
+ {
+ DEF_ARGS_EXTRA *value = (DEF_ARGS_EXTRA *) e->extra[i].value;
+ int j;
+ char *label;
+
+ text_append_n (text, "'", 1);
+ text_append (text, e->extra[i].key);
+ text_append (text, "' => [\n");
+
+ for (j = 0; (label = value->labels[j]); j++)
+ {
+ dump_indent (text);
+ text_append_n (text, "['", 2);
+ text_append (text, label);
+ text_append_n (text, "', ", 3);
+
+ dump_element (value->elements[j], text);
+ text_append_n (text, "],\n", 3);
+ }
+ dump_indent (text);
+ text_append_n (text, "],\n", 3);
+ /* TODO: Also output a "def_parsed_hash". */
+ }
else if (e->extra[i].value->parent_type == route_not_in_tree)
{
switch (e->extra[i].type)
Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/end_line.c 2015-03-23 14:24:49 UTC (rev 6193)
@@ -1048,8 +1048,7 @@
/* 3350 */
if (cmd == CM_setfilename && (current_node || current_section))
{
- /* warning */
- abort ();
+ command_warn ("@setfilename after the first element");
}
/* 3355 columnfractions */
else if (cmd == CM_columnfractions)
@@ -1185,27 +1184,80 @@
}
}
- /* Is it a def line 2778 */
+ /* End of a definition line, like @deffn */ // 2778
else if (current->parent && current->parent->type == ET_def_line)
{
enum element_type def_command;
+ DEF_ARGS_EXTRA *arguments = 0;
if (pop_context () != ct_def)
- {
- abort ();
- }
+ abort ();
-#if 0
/* current->parent is a ET_def_line, and current->parent->parent
the def command. */
def_command = current->parent->parent->cmd;
- // strip a trailing x
- parse_def (def_command, current->contents);
-#endif
+ /* Strip an trailing x from the command, e.g. @deffnx -> @deffn */
+ if (command_data(def_command).flags & CF_misc)
+ {
+ char *stripped = strdup (command_name(def_command));
+ stripped[strlen (stripped) - 1] = '\0';
+ def_command = lookup_command (stripped);
+ free (stripped);
+ }
- current = current->parent->parent;
+ arguments = parse_def (def_command, current->contents);
+
+ /* Now record the index entry. */
+ if (arguments)
+ {
+ ELEMENT *name = 0, *class = 0; /* From arguments. */
+ ELEMENT *index_entry = 0; /* Index entry text. */
+ char *label;
+ int i;
+
+ add_extra_def_args (current->parent, "def_args", arguments);
+
+ /* We use the keys "name" and "class" from the arguments. */
+ for (i = 0; (label = arguments->labels[i]); i++)
+ {
+ if (!strcmp (label, "name"))
+ name = arguments->elements[i];
+ else if (!strcmp (label, "class"))
+ class = arguments->elements[i];
+ }
+
+ if (name) // 2811
+ {
+ if (name->type == ET_bracketed_def_content
+ && (name->contents.number == 0
+ || (name->contents.number == 1
+&& name->contents.list[0]->text.text[
+strspn (name->contents.list[0]->text.text, whitespace_chars)] == '\0')))
+ {
+ }
+ else
+ index_entry = name;
+ }
+
+ if (index_entry) // 2822
+ {
+
+ // enter_index_entry (); // 2853
+ }
+ else
+ {
+ command_warnf ("missing name for @%s",
+ "<original_def_cmdname>"); // TODO
+ }
+ }
+ else
+ {
+ command_warnf ("missing category for @%s",
+ "<original_def_cmdname>"); // TODO
+ }
+
+ current = current->parent->parent; // 2868
current = begin_preformatted (current);
-
}
// 2872
Modified: trunk/parsetexi/extra.c
===================================================================
--- trunk/parsetexi/extra.c 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/extra.c 2015-03-23 14:24:49 UTC (rev 6193)
@@ -98,6 +98,13 @@
}
void
+add_extra_def_args (ELEMENT *e, char *key, DEF_ARGS_EXTRA *value)
+{
+ add_extra_key (e, key, (ELEMENT *) value);
+ e->extra[e->extra_number - 1].type = extra_def_args;
+}
+
+void
add_extra_string (ELEMENT *e, char *key, char *value)
{
add_extra_key (e, key, (ELEMENT *) value);
Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/handle_commands.c 2015-03-23 14:24:49 UTC (rev 6193)
@@ -325,7 +325,10 @@
/* Find the command with "x" stripped from the end, e.g.
deffnx -> deffn. */
- base_name = strdup (command_name(cmd));
+ base_name = command_name(cmd);
+ add_extra_string (misc, "original_def_cmdname", base_name);
+
+ base_name = strdup (base_name);
base_len = strlen (base_name);
if (base_name[base_len - 1] != 'x')
abort ();
@@ -333,11 +336,11 @@
base_command = lookup_command (base_name);
if (base_command == CM_NONE)
abort ();
- free (base_name);
+ add_extra_string (misc, "def_command", base_name);
//check_no_text ();
push_context (ct_def);
- misc->type = ET_def_line;
+ misc->type = ET_def_line; // 4553
if (current->cmd == base_command)
{
// Does this gather an "inter_def_item" ?
@@ -481,6 +484,9 @@
def_line = new_element (ET_def_line);
add_to_element_contents (current, def_line);
current = def_line;
+ add_extra_string (current, "def_command", command_name(cmd));
+ add_extra_string (current, "original_def_cmdname",
+ command_name(cmd));
}
else
{
Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/parser.h 2015-03-23 14:24:49 UTC (rev 6193)
@@ -76,6 +76,7 @@
void add_extra_key_misc_args (ELEMENT *e, char *key, ELEMENT *value);
void add_extra_node_spec (ELEMENT *e, char *key, NODE_SPEC_EXTRA *value);
void add_extra_node_spec_array (ELEMENT *, char *, NODE_SPEC_EXTRA **value);
+void add_extra_def_args (ELEMENT *e, char *key, DEF_ARGS_EXTRA *value);
void add_extra_string (ELEMENT *e, char *key, char *value);
KEY_PAIR *lookup_extra_key (ELEMENT *e, char *key);
Modified: trunk/parsetexi/tree_types.h
===================================================================
--- trunk/parsetexi/tree_types.h 2015-03-15 09:54:26 UTC (rev 6192)
+++ trunk/parsetexi/tree_types.h 2015-03-23 14:24:49 UTC (rev 6193)
@@ -35,6 +35,7 @@
extra_node_spec,
extra_node_spec_array,
extra_string,
+ extra_def_args,
extra_deleted
};
@@ -144,3 +145,11 @@
char *normalized;
} NODE_SPEC_EXTRA;
+typedef struct {
+ char **labels;
+ ELEMENT **elements;
+ int nelements;
+ int space;
+} DEF_ARGS_EXTRA;
+
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6193] parsetexi def line,
Gavin D. Smith <=