texinfo-commits
[Top][All Lists]
Advanced

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

[7176] parsetexi update


From: gavinsmith0123
Subject: [7176] parsetexi update
Date: Sun, 22 May 2016 17:42:15 +0000 (UTC)

Revision: 7176
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7176
Author:   gavin
Date:     2016-05-22 17:42:15 +0000 (Sun, 22 May 2016)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/tp/parsetexi/ChangeLog
    trunk/tp/parsetexi/api.c
    trunk/tp/parsetexi/close.c
    trunk/tp/parsetexi/handle_commands.c
    trunk/tp/parsetexi/handle_commands.h
    trunk/tp/parsetexi/parser.c
    trunk/tp/parsetexi/parser.h

Modified: trunk/tp/parsetexi/ChangeLog
===================================================================
--- trunk/tp/parsetexi/ChangeLog        2016-05-22 12:59:11 UTC (rev 7175)
+++ trunk/tp/parsetexi/ChangeLog        2016-05-22 17:42:15 UTC (rev 7176)
@@ -1,3 +1,7 @@
+2016-05-22  Gavin Smith  <address@hidden>
+
+       * parser.c (mark_and_warn_invalid): Implement.
+
 2016-05-14  Gavin Smith  <address@hidden>
 
        * Parsetexi.pm: Remove commented-out code to use other methods 

Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c    2016-05-22 12:59:11 UTC (rev 7175)
+++ trunk/tp/parsetexi/api.c    2016-05-22 17:42:15 UTC (rev 7176)
@@ -351,7 +351,8 @@
             case extra_element_contents:
               {
               int j;
-              STORE(build_perl_array (&f->contents));
+              if (f)
+                STORE(build_perl_array (&f->contents));
               break;
               }
             case extra_element_contents_array:

Modified: trunk/tp/parsetexi/close.c
===================================================================
--- trunk/tp/parsetexi/close.c  2016-05-22 12:59:11 UTC (rev 7175)
+++ trunk/tp/parsetexi/close.c  2016-05-22 17:42:15 UTC (rev 7176)
@@ -256,7 +256,8 @@
       debug ("CLOSING (close_current) %s", command_name(current->cmd));
       if (command_flags(current) & CF_brace)
         {
-          // pop_context ();
+          if (command_data(current->cmd).data == BRACE_context)
+            pop_context ();
           current = close_brace_command (current,
                                          closed_command, interrupting_command);
         }
@@ -285,6 +286,11 @@
               /* FIXME: Why not avoid adding the element
                  in the first place? */
             }
+          if (command_flags(current)
+              & (CF_preformatted | CF_menu | CF_format_raw))
+            {
+              pop_context ();
+            }
           current = current->parent;
         }
       else
@@ -337,9 +343,9 @@
     }
   else
     {
+      /* should never get here */
       if (current->parent)
         current = current->parent;
-      /* error */
     }
 
   return current;

Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c        2016-05-22 12:59:11 UTC (rev 
7175)
+++ trunk/tp/parsetexi/handle_commands.c        2016-05-22 17:42:15 UTC (rev 
7176)
@@ -1,5 +1,5 @@
 /* handle_commands.c -- what to do when a command name is first read */
-/* Copyright 2010, 2011, 2012, 2013, 2014, 2015
+/* Copyright 2010, 2011, 2012, 2013, 2014, 2015, 2016
    Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -173,7 +173,8 @@
 /* STATUS is set to 1 if we should get a new line after this. */
 ELEMENT *
 handle_misc_command (ELEMENT *current, char **line_inout,
-                     enum command_id cmd, int *status)
+                     enum command_id cmd, int *status,
+                     enum command_id invalid_parent)
 {
   ELEMENT *misc = 0;
   char *line = *line_inout;
@@ -290,7 +291,7 @@
         {
         } */
 
-      // mark_and_warn_invalid ();
+      mark_and_warn_invalid (cmd, invalid_parent, misc);
       register_global_command (cmd, misc); // 4423
 
       if (arg_spec != MISC_special /* || !has_comment */ )
@@ -651,9 +652,9 @@
         }
     }
 
-  /* line 4622 */
-  /* mark_and_warn_invalid (); */ /* possible error message due to invalid
-                                     nesting */
+  // 4622
+  mark_and_warn_invalid (cmd, invalid_parent, misc);
+
   register_global_command (cmd, misc);
 
 funexit:
@@ -745,7 +746,8 @@
    "end_line_misc_line" in end_line.c processes the @end command. */
 ELEMENT *
 handle_block_command (ELEMENT *current, char **line_inout,
-                      enum command_id cmd, int *get_new_line)
+                      enum command_id cmd, int *get_new_line,
+                      enum command_id invalid_parent)
 {
   char *line = *line_inout;
   unsigned long flags = command_data(cmd).flags;
@@ -756,7 +758,8 @@
       ELEMENT *macro;
       macro = parse_macro_command_line (cmd, &line, current);
       add_to_element_contents (current, macro);
-      // mark_and_warn_invalid ();
+      mark_and_warn_invalid (cmd, invalid_parent,
+                             last_contents_child(current));
       current = macro;
 
       /* 4640 */
@@ -995,7 +998,7 @@
 
           }
         } /* 4827 */
-      // mark_and_warn_invalid ();
+      mark_and_warn_invalid (cmd, invalid_parent, block);
       register_global_command (cmd, block);
       start_empty_line_after_command (current, &line, block);
     }
@@ -1008,7 +1011,8 @@
 /* 4835 */
 ELEMENT *
 handle_brace_command (ELEMENT *current, char **line_inout,
-                      enum command_id cmd)
+                      enum command_id cmd,
+                      enum command_id invalid_parent)
 {
   char *line = *line_inout;
   ELEMENT *e;
@@ -1027,8 +1031,8 @@
   add_to_element_contents (current, e);
   current = e;
 
-  // mark_and_warn_invalid
-  // click, kbd, definfoenclose
+  mark_and_warn_invalid (cmd, invalid_parent, e);
+  // TODO kbd
   if (cmd == CM_click)
     {
       add_extra_string (e, "clickstyle", global_clickstyle);

Modified: trunk/tp/parsetexi/handle_commands.h
===================================================================
--- trunk/tp/parsetexi/handle_commands.h        2016-05-22 12:59:11 UTC (rev 
7175)
+++ trunk/tp/parsetexi/handle_commands.h        2016-05-22 17:42:15 UTC (rev 
7176)
@@ -1,10 +1,13 @@
 
 ELEMENT *handle_misc_command (ELEMENT *current, char **line_inout,
-                     enum command_id cmd_id, int *status);
+                     enum command_id cmd_id, int *status,
+                     enum command_id invalid_parent);
 ELEMENT *handle_block_command (ELEMENT *current, char **line_inout,
-                      enum command_id cmd_id, int *new_line);
+                      enum command_id cmd_id, int *new_line,
+                      enum command_id invalid_parent);
 ELEMENT *handle_brace_command (ELEMENT *current, char **line_inout,
-                               enum command_id cmd_id);
+                               enum command_id cmd_id,
+                               enum command_id invalid_parent);
 int check_no_text (ELEMENT *current);
 int register_global_command (enum command_id cmd, ELEMENT *current);
 

Modified: trunk/tp/parsetexi/parser.c
===================================================================
--- trunk/tp/parsetexi/parser.c 2016-05-22 12:59:11 UTC (rev 7175)
+++ trunk/tp/parsetexi/parser.c 2016-05-22 17:42:15 UTC (rev 7176)
@@ -614,8 +614,6 @@
 }
 
 
-/* Parts of parse_texi lines 3676 - 5372 */
-
 /* If the parent element takes a command as an argument, like
    @itemize @bullet. */
 int
@@ -629,6 +627,25 @@
   // all non-whitespace characters??
 }
 
+// 3633
+/* If INVALID_PARENT is defined, then that command was used in the input
+   document and contained, incorrectly, a COMMAND command. Issue
+   a warning message. */
+void
+mark_and_warn_invalid (enum command_id command,
+                       enum command_id invalid_parent,
+                       ELEMENT *marked_as_invalid_command)
+{
+  if (invalid_parent)
+    {
+      line_warn ("@%s should not appear in @%s",
+                 command_name(command),
+                 command_name(invalid_parent));
+      if (marked_as_invalid_command)
+        add_extra_string (marked_as_invalid_command, "invalid_nesting", "1");
+    }
+}
+
 /* Used at line 3755 */
 /* Check if line is "@end ..." for current command.  If so, advance LINE. */
 int
@@ -1091,11 +1108,10 @@
   /* Any other @-command. */
   else if (cmd)
     {
+      enum command_id invalid_parent = 0;
       line = line_after_command;
       debug ("COMMAND %s", command_name(cmd));
 
-      /* TODO: Check if this is an alias command */
-
       /* 4172 @value */
       if (cmd == CM_value)
         {
@@ -1196,12 +1212,37 @@
                      command_name(cmd));
         }
 
-#if 0
       /* 4233 invalid nestings */
-#endif
+      if (current->parent && current->parent->cmd)
+        {
+          int ok = 0;
+          enum command_id outer = current->parent->cmd;
+          unsigned long outer_flags = command_data(outer).flags;
 
+          // much TODO here.
+
+          if (outer_flags & CF_index_entry_command)
+            {
+              // 563 in_simple_text_commands
+              if (outer_flags & (CF_brace | CF_nobrace))
+                ok = 1;
+              if (cmd == CM_caption
+                  || cmd == CM_shortcaption)
+                ok = 0;
+            }
+          else
+            {
+              ok = 1;
+            }
+
+          if (!ok)
+            invalid_parent = current->parent->cmd;
+        }
+      /* 4258 TODO in def */
+
       /* 4276 check command doesn't start a paragraph */
-      /* TODO store this in cmd->flags */
+      /* TODO store this in cmd->flags.  Or better, change the meaning
+         of CF_misc. */
       if (!(command_data(cmd).flags & (CF_misc | CF_block)
             || cmd == CM_titlefont
             || cmd == CM_caption
@@ -1250,7 +1291,8 @@
       else if (command_data(cmd).flags & CF_misc)
         {
           int status;
-          current = handle_misc_command (current, &line, cmd, &status);
+          current = handle_misc_command (current, &line, cmd, &status,
+                                         invalid_parent);
           if (status == 1)
             {
               retval = GET_A_NEW_LINE;
@@ -1262,7 +1304,8 @@
       else if (command_data(cmd).flags & CF_block)
         {
           int new_line = 0;
-          current = handle_block_command (current, &line, cmd, &new_line);
+          current = handle_block_command (current, &line, cmd, &new_line,
+                                          invalid_parent);
           if (new_line)
             {
               /* For @macro, to get a new line.  This is done instead of
@@ -1274,7 +1317,8 @@
       else if (command_data(cmd).flags & CF_brace
                || command_data(cmd).flags & CF_accent) /* line 4835 */
         {
-          current = handle_brace_command (current, &line, cmd);
+          current = handle_brace_command (current, &line,
+                                          cmd, invalid_parent);
         }
 
       /* No-brace command */

Modified: trunk/tp/parsetexi/parser.h
===================================================================
--- trunk/tp/parsetexi/parser.h 2016-05-22 12:59:11 UTC (rev 7175)
+++ trunk/tp/parsetexi/parser.h 2016-05-22 17:42:15 UTC (rev 7176)
@@ -58,6 +58,9 @@
                         enum command_id interrupting_command);
 void isolate_last_space (ELEMENT *current, enum element_type type);
 int command_with_command_as_argument (ELEMENT *current);
+void mark_and_warn_invalid (enum command_id command,
+                            enum command_id invalid_parent,
+                            ELEMENT *marked_as_invalid_command);
 ELEMENT *begin_preformatted (ELEMENT *current);
 ELEMENT *end_preformatted (ELEMENT *current,
                            enum command_id closed_command,




reply via email to

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