[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7160] parsetexi work on conditionals
From: |
gavinsmith0123 |
Subject: |
[7160] parsetexi work on conditionals |
Date: |
Thu, 12 May 2016 19:35:26 +0000 (UTC) |
Revision: 7160
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7160
Author: gavin
Date: 2016-05-12 19:35:25 +0000 (Thu, 12 May 2016)
Log Message:
-----------
parsetexi work on conditionals
Modified Paths:
--------------
trunk/tp/parsetexi/api.c
trunk/tp/parsetexi/commands.h
trunk/tp/parsetexi/handle_commands.c
trunk/tp/parsetexi/parser.c
trunk/tp/parsetexi/separator.c
Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c 2016-05-08 17:43:39 UTC (rev 7159)
+++ trunk/tp/parsetexi/api.c 2016-05-12 19:35:25 UTC (rev 7160)
@@ -57,7 +57,7 @@
void
parse_file (char *filename)
{
- debug_output = 0;
+ debug_output = 1;
reset_parser ();
parse_texi_file (filename);
}
Modified: trunk/tp/parsetexi/commands.h
===================================================================
--- trunk/tp/parsetexi/commands.h 2016-05-08 17:43:39 UTC (rev 7159)
+++ trunk/tp/parsetexi/commands.h 2016-05-12 19:35:25 UTC (rev 7160)
@@ -58,7 +58,7 @@
#define CF_regular_font_style 0x0200
#define CF_in_heading 0x0400
#define CF_ref 0x0800
-#define CF_explained 0x1000
+/* free 0x1000 */
#define CF_block 0x2000
#define CF_raw 0x4000
#define CF_format_raw 0x8000
Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c 2016-05-08 17:43:39 UTC (rev
7159)
+++ trunk/tp/parsetexi/handle_commands.c 2016-05-12 19:35:25 UTC (rev
7160)
@@ -724,14 +724,88 @@
*get_new_line = 1;
goto funexit;
}
- else if (command_data(cmd).data == BLOCK_conditional)
+ else if (command_data(cmd).data == BLOCK_conditional) //4641
{
+ int iftrue = 0; /* Whether the conditional is true. */
+ if (cmd == CM_ifclear || cmd == CM_ifset
+ || cmd == CM_ifcommanddefined || cmd == CM_ifcommandnotdefined)
+ {
+ char *flag;
+ char *p = line;
+ p = line + strspn (line, whitespace_chars);
+ if (!*p)
+ line_error ("@%s requires a name", command_name(cmd));
+ else
+ {
+ flag = read_command_name (&p);
+ if (!flag)
+ goto bad_value;
+ else
+ {
+ p += strspn (p, whitespace_chars);
+ /* Check for a comment at the end of the line. */
+ if (memcmp (p, "@c", 2) == 0)
+ {
+ p += 2;
+ if (memcmp (p, "omment", 6) == 0)
+ p += 7;
+ if (*p && *p != '@' && !strchr (whitespace_chars, *p))
+ goto bad_value; /* @c or @comment not terminated. */
+ }
+ else if (*p)
+ goto bad_value; /* Trailing characters on line. */
+ }
+ if (1)
+ {
+ // 4652
+ if (cmd == CM_ifclear || cmd == CM_ifset)
+ {
+ char *val = fetch_value (flag, strlen (flag));
+ if (val)
+ iftrue = 1;
+ if (cmd == CM_ifclear)
+ iftrue = !iftrue;
+ }
+ else /* cmd == CM_ifcommanddefined
+ || cmd == CM_ifcommandnotdefined */
+ {
+ enum command_id c = lookup_command (flag);
+ if (c)
+ iftrue = 1;
+ if (cmd == CM_ifcommandnotdefined)
+ iftrue = !iftrue;
+ }
+ debug ("CONDITIONAL @%s %s: %d", command_name(cmd), flag,
+ iftrue);
+ }
+ else if (0)
+ {
+ bad_value:
+ line_error ("bad name for @%s", command_name(cmd));
+ }
+
+ }
+ }
+ else if (!memcmp (command_name(cmd), "ifnot", 5))
+ {
+ /* FIXME: Check @ifnot* a nicer way. */
+ // TODO
+ }
+ else if (!memcmp (command_name(cmd), "if", 2))
+ {
+ // TODO
+ }
+ else
+ abort (); // BUG
+
+
// 4699 - If conditional true, push onto conditional stack. Otherwise
- // open a new element (which we shall later remove).
+ // open a new element (which we shall later remove, in
+ // process_remaining_on_line ("CLOSED (conditional)").
debug ("CONDITIONAL %s", command_name(cmd));
- if (cmd != CM_ifnotinfo && cmd != CM_iftex) // TODO
- push_conditional_stack (cmd); // Not ignored
+ if (iftrue)
+ push_conditional_stack (cmd);
else
{
// Ignored.
Modified: trunk/tp/parsetexi/parser.c
===================================================================
--- trunk/tp/parsetexi/parser.c 2016-05-08 17:43:39 UTC (rev 7159)
+++ trunk/tp/parsetexi/parser.c 2016-05-12 19:35:25 UTC (rev 7160)
@@ -211,7 +211,7 @@
if (current->contents.number > 0)
{
int i = current->contents.number - 1;
- while (i > 0)
+ while (i >= 0)
{
ELEMENT *child = contents_child_by_index (current, i);
if (child->type == ET_empty_line
@@ -323,6 +323,7 @@
if (last_child
&& (last_child->type == ET_empty_line_after_command
+ || last_child->type == ET_empty_spaces_after_command
|| last_child->type == ET_empty_spaces_before_argument
|| last_child->type == ET_empty_spaces_after_close_brace))
{
@@ -785,8 +786,15 @@
abort(); //error
destroy_element_and_children (popped);
- // abort until end of line, calling new_line
+ /* Ignore until end of line */
+ if (!strchr (line, '\n'))
+ {
+ debug ("IGNORE CLOSE LINE");
+ line = new_line ();
+ }
debug ("CLOSED conditional %s", command_name(end_cmd));
+ retval = GET_A_NEW_LINE;
+ goto funexit;
}
else
{
Modified: trunk/tp/parsetexi/separator.c
===================================================================
--- trunk/tp/parsetexi/separator.c 2016-05-08 17:43:39 UTC (rev 7159)
+++ trunk/tp/parsetexi/separator.c 2016-05-12 19:35:25 UTC (rev 7160)
@@ -335,11 +335,14 @@
else if (closed_command == CM_dotless)
{
}
- else if (command_data(closed_command).flags & (CF_explained | CF_inline))
+ else if ((command_data(closed_command).flags & CF_inline)
+ || closed_command == CM_abbr
+ || closed_command == CM_acronym)
{ // 5129
/* TODO: For @abbr and @acronym, keep track of whether an expansion
for the abbreviation has been given. This is used in the HTML
- output for the <abbr title> attribute. */
+ output for the <abbr title> attribute. Or we could just move
+ the code to HTML.pm. */
}
else if (closed_command == CM_errormsg) // 5173
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7160] parsetexi work on conditionals,
gavinsmith0123 <=