[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[6180] parsetexi update
From: |
Gavin D. Smith |
Subject: |
[6180] parsetexi update |
Date: |
Fri, 06 Mar 2015 21:40:11 +0000 |
Revision: 6180
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6180
Author: gavin
Date: 2015-03-06 21:40:09 +0000 (Fri, 06 Mar 2015)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/parsetexi/ChangeLog
trunk/parsetexi/TODO
trunk/parsetexi/api.c
trunk/parsetexi/close.c
trunk/parsetexi/commands.h
trunk/parsetexi/convert.c
trunk/parsetexi/end_line.c
trunk/parsetexi/handle_commands.c
trunk/parsetexi/macro.c
trunk/parsetexi/parser.c
trunk/parsetexi/parser.h
trunk/parsetexi/separator.c
trunk/parsetexi/tree_types.h
Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/ChangeLog 2015-03-06 21:40:09 UTC (rev 6180)
@@ -1,6 +1,7 @@
2015-03-06 Gavin Smith <address@hidden>
* counter.c: New file.
+ * commands.h (command_name): New macro.
2015-03-01 Gavin Smith <address@hidden>
Modified: trunk/parsetexi/TODO
===================================================================
--- trunk/parsetexi/TODO 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/TODO 2015-03-06 21:40:09 UTC (rev 6180)
@@ -1,6 +1,6 @@
* conditionals on @set/@value, output format
-* Counters for e.g. numbers of arguments read so far for a brace
-command, or the row in a table.
+* Check everywhere we store values, we check properly what to do if the
+ values are already defined.
* check valid nestings
* @deffn, @deffnx, etc.
* Implement parser options
Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/api.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -167,7 +167,7 @@
if (e->cmd)
{
- sv = newSVpv (command_data(e->cmd).cmdname, 0);
+ sv = newSVpv (command_name(e->cmd), 0);
hv_store (e->hv, "cmdname", strlen ("cmdname"), sv, 0);
/* TODO: Same optimizations as for 'type'. */
@@ -441,9 +441,9 @@
STORE2("index_name", newSVpv (i->name, 0));
STORE2("index_prefix", newSVpv (i->name, 1));
STORE2("index_at_command",
- newSVpv (command_data(e->index_at_command).cmdname, 0));
+ newSVpv (command_name(e->index_at_command), 0));
STORE2("index_type_command",
- newSVpv (command_data(e->index_type_command).cmdname, 0));
+ newSVpv (command_name(e->index_type_command), 0));
STORE2("command",
newRV_inc ((SV *)e->command->hv));
STORE2("number", newSViv (j));
Modified: trunk/parsetexi/close.c
===================================================================
--- trunk/parsetexi/close.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/close.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -18,9 +18,6 @@
#include "parser.h"
#include "errors.h"
-/* In parser.c. */
-ELEMENT *end_paragraph (ELEMENT *current);
-
// 1512
void
close_command_cleanup (ELEMENT *current)
@@ -30,6 +27,12 @@
if (current->cmd == CM_multitable)
{
+ if (counter_value (&count_cells, current) != -1)
+ counter_pop (&count_cells);
+ /* TODO
+ if (counter_value (&max_columns, current) != -1)
+ counter_pop (&count_cells);
+ */
}
else if (current->cmd == CM_itemize || current->cmd == CM_enumerate)
{
@@ -69,7 +72,7 @@
/* Element is a command */
if (current->cmd)
{
- debug ("CLOSING (close_current) %s", command_data(current->cmd).cmdname);
+ debug ("CLOSING (close_current) %s", command_name(current->cmd));
current = current->parent; /* TODO */
}
else if (current->type != ET_NONE)
@@ -173,7 +176,7 @@
}
else if (closed_command)
{
- line_errorf ("unmatched @end %s", command_data(closed_command).cmdname);
+ line_errorf ("unmatched @end %s", command_name(closed_command));
}
return current;
Modified: trunk/parsetexi/commands.h
===================================================================
--- trunk/parsetexi/commands.h 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/commands.h 2015-03-06 21:40:09 UTC (rev 6180)
@@ -34,6 +34,7 @@
: user_defined_command_data[(id) & ~USER_COMMAND_BIT])
#define command_flags(e) (command_data((e)->cmd).flags)
+#define command_name(cmd) (command_data(cmd).cmdname)
enum command_id add_texinfo_command (char *name);
Modified: trunk/parsetexi/convert.c
===================================================================
--- trunk/parsetexi/convert.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/convert.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -78,7 +78,7 @@
case CM_CLOSE_BRACE:
case CM_OPEN_BRACE:
case CM_BACKSLASH:
- ADD(command_data(root->cmd).cmdname);
+ ADD(command_name(root->cmd));
break;
default:
/* Shouldn't get here. */
Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/end_line.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -364,7 +364,7 @@
break;
defindex_invalid:
line_errorf ("bad argument to @%s: %s",
- command_data(cmd).cmdname, line);
+ command_name(cmd), line);
break;
defindex_reserved:
line_errorf ("reserved index name %s", name);
@@ -398,7 +398,7 @@
break;
synindex_invalid:
line_errorf ("bad argument to @%s: %s",
- command_data(cmd).cmdname, line);
+ command_name(cmd), line);
free (from); free (to);
break;
}
@@ -421,7 +421,7 @@
}
else
line_errorf ("@%s argument must be `top' or `bottom', not `%s'",
- command_data(cmd).cmdname, line);
+ command_name(cmd), line);
break;
}
@@ -823,7 +823,7 @@
static ELEMENT *
end_line_misc_line (ELEMENT *current)
{
- enum command_id cmd_id;
+ enum command_id cmd;
int arg_type;
enum context c;
ELEMENT *misc_cmd;
@@ -834,11 +834,11 @@
current = current->parent;
misc_cmd = current;
- cmd_id = current->cmd;
- if (!cmd_id)
+ cmd = current->cmd;
+ if (!cmd)
abort ();
- arg_type = command_data(cmd_id).data;
+ arg_type = command_data(cmd).data;
/* Check 'line' is top of the context stack */
c = pop_context ();
@@ -849,7 +849,7 @@
}
// 3114
- debug ("MISC END %s", command_data(cmd_id).cmdname);
+ debug ("MISC END %s", command_name(cmd));
if (arg_type > 0)
{
@@ -875,7 +875,7 @@
if (!text || !strcmp (text, ""))
{
// 3123
- line_warnf ("@%s missing argument", command_data(cmd_id).cmdname);
+ line_warnf ("@%s missing argument", command_name(cmd));
}
else
{
@@ -1039,20 +1039,20 @@
} /* 3340 */
else
{
- if (close_preformatted_command (cmd_id))
+ if (close_preformatted_command (cmd))
current = begin_preformatted (current);
}
/* 3346 included file */
/* 3350 */
- if (cmd_id == CM_setfilename && (current_node || current_section))
+ if (cmd == CM_setfilename && (current_node || current_section))
{
/* warning */
abort ();
}
/* 3355 columnfractions */
- else if (cmd_id == CM_columnfractions)
+ else if (cmd == CM_columnfractions)
{
ELEMENT *before_item;
KEY_PAIR *misc_args;
@@ -1077,10 +1077,10 @@
add_to_element_contents (current, before_item);
current = before_item;
}
- else if (command_data(cmd_id).flags & CF_root) /* 3380 */
+ else if (command_data(cmd).flags & CF_root) /* 3380 */
{
current = last_contents_child (current);
- if (cmd_id == CM_node)
+ if (cmd == CM_node)
counter_pop (&count_remaining_args);
/* 3383 Destroy all contents (why do we do this?) */
@@ -1088,7 +1088,7 @@
destroy_element (pop_element_from_contents (current));
/* Set 'associated_section' extra key for a node. */
- if (cmd_id != CM_node && cmd_id != CM_part)
+ if (cmd != CM_node && cmd != CM_part)
{
if (current_node)
{
Modified: trunk/parsetexi/handle_commands.c
===================================================================
--- trunk/parsetexi/handle_commands.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/handle_commands.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -170,14 +170,14 @@
if (cmd == CM_item || cmd == CM_itemx
|| cmd == CM_headitem || cmd == CM_tab)
{
- ELEMENT *parent;
+ ELEMENT *misc, *parent;
// itemize or enumerate 4443
if ((parent = item_container_parent (current)))
{
if (cmd == CM_item)
{
- ELEMENT *misc; char *s;
+ char *s;
debug ("ITEM CONTAINER");
counter_inc (&count_items);
misc = new_element (ET_NONE);
@@ -202,8 +202,6 @@
{
if (cmd == CM_item || cmd == CM_itemx)
{
- ELEMENT *misc;
-
debug ("ITEM_LINE");
current = parent;
// gather_previous_item ();
@@ -213,14 +211,15 @@
line_arg = 1;
}
}
- // multitable
+ /* In a @multitable */
else if ((parent = item_multitable_parent (current))) // 4477
{
if (cmd != CM_item && cmd != CM_headitem
&& cmd != CM_tab)
{
- /* 4521 error - not meaningful */
- abort ();
+ line_errorf ("@%s not meaningful inside @%s block",
+ command_name(cmd),
+ command_name(parent->cmd)); // 4521
}
else
{ /* 4480 */
@@ -234,52 +233,71 @@
row = last_contents_child (parent);
if (row->type == ET_before_item)
- abort ();/* error */
- /* else if too many columns */
+ line_error ("@tab before @item");
+ /* TODO 4489
+ else if (counter_value (&count_cells, row)
+ >= counter_value (&max_columns, parent))
+ {
+ line_error ("too many columns in multitable item"
+ " (max %d)",
+ counter_value (&max_columns, parent));
+ }
+ */
else // 4493
{
- ELEMENT *misc;
+ char *s;
+ counter_inc (&count_cells);
misc = new_element (ET_NONE);
misc->cmd = cmd;
add_to_element_contents (row, misc);
current = misc;
debug ("TAB");
- /* TODO: Keep count. */
- add_extra_string (current, "cell_number", "2");
+ asprintf (&s, "%d",
+ counter_value (&count_cells, parent));
+ add_extra_string (current, "cell_number", s);
}
}
else /* 4505 @item or @headitem */
{
- ELEMENT *row, *misc;
+ ELEMENT *row; char *s;
debug ("ROW");
row = new_element (ET_row);
add_to_element_contents (parent, row);
+ /* The Perl code sets the "row_number" extra value,
+ although it doesn't look it is used anywhere. */
+
misc = new_element (ET_NONE);
misc->cmd = cmd;
add_to_element_contents (row, misc);
current = misc;
- /* TODO: Keep count. */
- add_extra_string (current, "cell_number", "1");
+ if (counter_value (&count_cells, parent) != -1)
+ counter_pop (&count_cells);
+ counter_push (&count_cells, row, 1);
+ asprintf (&s, "%d",
+ counter_value (&count_cells, parent));
+ add_extra_string (current, "cell_number", s);
}
}
- } /* item_multitable_parent */
+ } /* In @multitable */
else if (cmd == CM_tab) // 4526
{
- // error - tab outside of multitable
+ line_error ("ignoring @tab outside of multitable");
current = begin_preformatted (current);
}
else
{
- /* error */
- // this is reached too much at the moment
- //abort ();
+ line_errorf ("@%s outside of table or list",
+ command_name(cmd));
current = begin_preformatted (current);
}
+ if (misc)
+ misc->line_nr = line_nr; // 4535
}
- else /* not item, itemx, headitem, nor tab 4536 */
+ /*************************************************************/
+ else /* Not @item, @itemx, @headitem, nor @tab 4536 */
{
/* Add to contents */
misc = new_element (ET_NONE);
@@ -301,7 +319,7 @@
/* Find the command with "x" stripped from the end, e.g.
deffnx -> deffn. */
- base_name = strdup (command_data(cmd).cmdname);
+ base_name = strdup (command_name(cmd));
base_len = strlen (base_name);
if (base_name[base_len - 1] != 'x')
abort ();
@@ -323,8 +341,8 @@
{
// error - deffnx not after deffn
line_errorf ("must be after @%s to use @%s",
- command_data(base_command).cmdname,
- command_data(cmd).cmdname);
+ command_name(base_command),
+ command_name(cmd));
}
}
} /* 4571 */
@@ -409,7 +427,7 @@
// 4699 - If conditional true, push onto conditional stack. Otherwise
// open a new element (which we shall later remove).
- debug ("CONDITIONAL %s", command_data(cmd).cmdname);
+ debug ("CONDITIONAL %s", command_name(cmd));
if (cmd != CM_ifnotinfo) // TODO
push_conditional_stack (cmd); // Not ignored
else
Modified: trunk/parsetexi/macro.c
===================================================================
--- trunk/parsetexi/macro.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/macro.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -214,8 +214,7 @@
line = new_line ();
if (!line)
{
- line_errorf ("@%s missing close brace",
- command_data(cmd).cmdname);
+ line_errorf ("@%s missing close brace", command_name(cmd));
line = "\n";
goto funexit;
}
Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/parser.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -112,13 +112,9 @@
/* Counters */
COUNTER count_remaining_args;
COUNTER count_items;
+COUNTER count_cells;
-/* lines 1-751 - comments, variable declarations, package imports,
- initializations, utilities */
-
-/* lines 751 - 983 - user-visible functions, entry points */
-/* parse_texi_file */
/* 835 */
void
parse_texi_file (const char *filename_in)
@@ -673,11 +669,11 @@
destroy_element (popped);
// abort until end of line, calling new_line
- debug ("CLOSED conditional %s", command_data(end_cmd).cmdname);
+ debug ("CLOSED conditional %s", command_name(end_cmd));
}
else
{
- debug ("CLOSED raw %s", command_data(end_cmd).cmdname);
+ debug ("CLOSED raw %s", command_name(end_cmd));
start_empty_line_after_command (current, &line); // 3831
}
}
@@ -845,7 +841,7 @@
/* TODO: Check 'IGNORE_SPACES_AFTER_BRACED_COMMAND_NAME' config
variable. */
line_errorf ("@%s expected braces",
- command_data(current->cmd).cmdname);
+ command_name(current->cmd));
current = current->parent;
}
}
@@ -859,7 +855,7 @@
else if (cmd)
{
line = line_after_command;
- debug ("COMMAND %s", command_data(cmd).cmdname);
+ debug ("COMMAND %s", command_name(cmd));
/* TODO: Check if this is an alias command */
@@ -1047,14 +1043,14 @@
if (current->type)
debug ("END LINE (%s)", element_type_names[current->type]);
else if (current->cmd)
- debug ("END LINE (@%s)", command_data(current->cmd).cmdname);
+ debug ("END LINE (@%s)", command_name(current->cmd));
else
debug ("END LINE");
if (current->parent)
{
debug_nonl (" <- ");
if (current->parent->cmd)
- debug_nonl("@%s", command_data(current->parent->cmd).cmdname);
+ debug_nonl("@%s", command_name(current->parent->cmd));
if (current->parent->type)
debug_nonl("(%s)", element_type_names[current->parent->type]);
debug ("");
Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/parser.h 2015-03-06 21:40:09 UTC (rev 6180)
@@ -84,4 +84,4 @@
#include "counter.h"
/* Defined in parser.c */
-extern COUNTER count_remaining_args, count_items;
+extern COUNTER count_remaining_args, count_items, count_cells;
Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/separator.c 2015-03-06 21:40:09 UTC (rev 6180)
@@ -20,6 +20,7 @@
#include "parser.h"
#include "tree.h"
#include "text.h"
+#include "error.h"
// 3600
/* Add the contents of CURRENT as an element to the extra value with
Modified: trunk/parsetexi/tree_types.h
===================================================================
--- trunk/parsetexi/tree_types.h 2015-03-06 18:27:03 UTC (rev 6179)
+++ trunk/parsetexi/tree_types.h 2015-03-06 21:40:09 UTC (rev 6180)
@@ -81,9 +81,6 @@
size_t extra_number;
size_t extra_space;
- /* Not used in final output. */
- int remaining_args; /* Could be a stack instead. */
-
/* Set to route_not_in_tree if element not in main tree. Also
used for routing information along with 'index_in_parent' when
dumping to a text stream. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [6180] parsetexi update,
Gavin D. Smith <=