texinfo-commits
[Top][All Lists]
Advanced

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

[6832] parsetexi update


From: Gavin D. Smith
Subject: [6832] parsetexi update
Date: Thu, 03 Dec 2015 18:26:22 +0000

Revision: 6832
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6832
Author:   gavin
Date:     2015-12-03 18:26:22 +0000 (Thu, 03 Dec 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/close.c
    trunk/parsetexi/command_data.txt
    trunk/parsetexi/commands.h
    trunk/parsetexi/end_line.c
    trunk/parsetexi/parser.c
    trunk/parsetexi/parser.h
    trunk/parsetexi/separator.c

Modified: trunk/parsetexi/close.c
===================================================================
--- trunk/parsetexi/close.c     2015-12-03 16:27:37 UTC (rev 6831)
+++ trunk/parsetexi/close.c     2015-12-03 18:26:22 UTC (rev 6832)
@@ -19,6 +19,54 @@
 #include "parser.h"
 #include "errors.h"
 
+// 1246
+/* Possibly print an error message, and return CURRENT->parent. */
+static ELEMENT *
+close_brace_command (ELEMENT *current,
+                     enum command_id closed_command,
+                     enum command_id interrupting_command)
+{
+  if (current->cmd != CM_verb || current->type == ET_NONE)
+    {
+      if (closed_command)
+        command_errorf ("@end %s seen before @%s closing brace",
+                        command_name(closed_command),
+                        command_name(current->cmd));
+      else if (interrupting_command)
+        command_errorf ("%s seen before @%s closing brace",
+                        command_name(interrupting_command),
+                        command_name(current->cmd));
+      else
+        command_errorf ("@%s missing close brace",
+                        command_name(current->cmd));
+    }
+  else
+    {
+      command_errorf ("@%s missing closing delimiter sequence: %s",
+                      command_name(current->cmd),
+                      element_type_names[current->type]);
+    }
+  current = current->parent;
+  return current;
+}
+
+// 1292
+/* Close out any brace commands that mark text, not allowing multiple
+   paragraphs. */
+ELEMENT *
+close_all_style_commands (ELEMENT *current,
+                          enum command_id closed_command,
+                          enum command_id interrupting_command)
+{
+  while (current->parent
+         && (command_flags(current->parent) & CF_brace)
+         && !(command_data(current->parent->cmd).data == BRACE_context))
+    current = close_brace_command (current->parent,
+                                   closed_command, interrupting_command);
+
+  return current;
+}
+
 // 1512
 void
 close_command_cleanup (ELEMENT *current)
@@ -185,13 +233,25 @@
 
 /* 1642 */
 static ELEMENT *
-close_current (ELEMENT *current)
+close_current (ELEMENT *current,
+               enum command_id closed_command,
+               enum command_id interrupting_command)
 {
   /* Element is a command */
   if (current->cmd)
     {
       debug ("CLOSING (close_current) %s", command_name(current->cmd));
-      current = current->parent; /* TODO */
+      if (command_flags(current) & CF_brace)
+        {
+          // pop_context ();
+          current = close_brace_command (current,
+                                         closed_command, interrupting_command);
+        }
+      else
+        {
+          current = current->parent;
+          // TODO
+        }
     }
   else if (current->type != ET_NONE)
     {
@@ -254,7 +314,7 @@
                 ELEMENT **closed_element, enum command_id interrupting)
 {
   *closed_element = 0;
-  current = end_paragraph (current);
+  current = end_paragraph (current, closed_command, interrupting);
   current = end_preformatted (current);
 
   while (current->parent
@@ -263,7 +323,7 @@
          && !(current->cmd && command_flags(current) & CF_root))
     {
       close_command_cleanup (current);
-      current = close_current (current);
+      current = close_current (current, closed_command, interrupting);
     }
 
   if (closed_command && current->cmd == closed_command)

Modified: trunk/parsetexi/command_data.txt
===================================================================
--- trunk/parsetexi/command_data.txt    2015-12-03 16:27:37 UTC (rev 6831)
+++ trunk/parsetexi/command_data.txt    2015-12-03 18:26:22 UTC (rev 6832)
@@ -148,12 +148,12 @@
 itemx                          misc            MISC_skipspace
 tab                            misc            MISC_skipspace
 # only valid in heading or footing
-thischapter                    misc            MISC_noarg
-thischaptername                        misc            MISC_noarg
-thischapternum                 misc            MISC_noarg
-thisfile                       misc            MISC_noarg
-thispage                       misc            MISC_noarg
-thistitle                      misc            MISC_noarg
+thischapter                    misc,in_heading         MISC_noarg
+thischaptername                        misc,in_heading         MISC_noarg
+thischapternum                 misc,in_heading         MISC_noarg
+thisfile                       misc,in_heading         MISC_noarg
+thispage                       misc,in_heading         MISC_noarg
+thistitle                      misc,in_heading         MISC_noarg
 # not valid for info (should be in @iftex)
 vskip                          misc            MISC_lineraw
 # obsolete @-commands.
@@ -161,6 +161,8 @@
 # Remove spaces and end of lines after the 
 # commands? If no, they can lead to empty lines
 # TODO: Check what these two are.
+# They were obsolete and undocumented commands for macro definitions,
+# never supported in texinfo.tex.
 #quote-arg                     misc            MISC_skipline
 #allow-recursion               misc            MISC_skipline
 

Modified: trunk/parsetexi/commands.h
===================================================================
--- trunk/parsetexi/commands.h  2015-12-03 16:27:37 UTC (rev 6831)
+++ trunk/parsetexi/commands.h  2015-12-03 18:26:22 UTC (rev 6832)
@@ -54,7 +54,7 @@
 /* CF_code_style is set for brace commands only. */
 #define CF_code_style                  0x0100
 #define CF_regular_font_style          0x0200
-// #define free                        0x0400
+#define CF_in_heading                  0x0400
 #define CF_ref                         0x0800
 #define CF_explained                   0x1000
 #define CF_block                       0x2000

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-12-03 16:27:37 UTC (rev 6831)
+++ trunk/parsetexi/end_line.c  2015-12-03 18:26:22 UTC (rev 6832)
@@ -1340,7 +1340,7 @@
           /* Remove empty_line element. */
           e = pop_element_from_contents (current);
 
-          current = end_paragraph (current);
+          current = end_paragraph (current, 0, 0);
 
           /* Add empty_line to higher-level element. */
           add_to_element_contents (current, e);
@@ -1379,7 +1379,7 @@
         }
       else if (in_paragraph_context (current_context ()))
         {
-          current = end_paragraph (current);
+          current = end_paragraph (current, 0, 0);
         }
     }
 

Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c    2015-12-03 16:27:37 UTC (rev 6831)
+++ trunk/parsetexi/parser.c    2015-12-03 18:26:22 UTC (rev 6832)
@@ -242,14 +242,16 @@
 
 /* 1310 */
 ELEMENT *
-end_paragraph (ELEMENT *current)
+end_paragraph (ELEMENT *current,
+               enum command_id closed_command,
+               enum command_id interrupting_command)
 {
-  /* close_all_style_commands (); */
-
+  current = close_all_style_commands (current,
+                                      closed_command, interrupting_command);
   if (current->type == ET_paragraph)
     {
+      debug ("CLOSE PARA");
       current = current->parent;
-      debug ("CLOSE PARA");
     }
 
   return current;
@@ -535,7 +537,7 @@
 /* Add an "ET_empty_line_after_command" element containing the whitespace at 
    the beginning of the rest of the line.  This element can be later changed 
to 
    a "ET_empty_spaces_after_command" element in 'abort_empty_line' if more
-   text follows on the line.  Used after line commmands or commands starting
+   text follows on the line.  Used after line commands or commands starting
    a block. */
 void
 start_empty_line_after_command (ELEMENT *current, char **line_inout,
@@ -864,7 +866,7 @@
      @definfoenclose. */
   /* This condition is only checked immediately after the command opening, 
      otherwise the current element is in the 'args' and not right in the 
-     commmand container. */
+     command container. */
   else if (!cmd && command_flags(current) & CF_brace && *line != '{')
     {
       if (command_with_command_as_argument (current->parent)) // 3988
@@ -980,10 +982,30 @@
       /* TODO: warn on deprecated command */
 
       /* warn on not appearing at line beginning 4226 */
-      if (!abort_empty_line (&current, NULL))
-        //  && begin_line_commands (command))
+      // begin line commands 315
+      // TODO maybe have a command flag for this
+      if (!abort_empty_line (&current, NULL)
+          && ((cmd == CM_node || cmd == CM_bye)
+              || (command_data(cmd).flags & CF_block)
+              || ((command_data(cmd).flags & CF_misc)
+                  && cmd != CM_comment
+                  && cmd != CM_c
+                  && cmd != CM_sp
+                  && cmd != CM_refill
+                  && cmd != CM_noindent
+                  && cmd != CM_indent
+                  && cmd != CM_columnfractions
+                  && cmd != CM_tab
+                  && cmd != CM_item
+                  && cmd != CM_headitem
+                  && cmd != CM_verbatiminclude
+                  && cmd != CM_set
+                  && cmd != CM_clear
+                  && cmd != CM_vskip)
+              || (command_data(cmd).flags & CF_in_heading)))
         {
-          /* warning */
+          line_warnf ("@%s should only appear at a line beginning",
+                      command_name(cmd));
         }
 
 #if 0
@@ -1022,7 +1044,7 @@
       if (cmd != 0)
         {
           if (close_paragraph_command (cmd))
-            current = end_paragraph (current);
+            current = end_paragraph (current, 0, 0);
           if (close_preformatted_command (cmd))
             current = end_preformatted (current);
         }
@@ -1210,7 +1232,7 @@
 #endif
 
     {
-      ELEMENT *dummy;
+      ELEMENT *dummy; // 5254
       current = close_commands (current, CM_NONE, &dummy, CM_NONE);
 
       /* Make sure we are at the very top - we could have stopped at the "top" 

Modified: trunk/parsetexi/parser.h
===================================================================
--- trunk/parsetexi/parser.h    2015-12-03 16:27:37 UTC (rev 6831)
+++ trunk/parsetexi/parser.h    2015-12-03 18:26:22 UTC (rev 6832)
@@ -14,6 +14,9 @@
 void close_command_cleanup (ELEMENT *current);
 ELEMENT *close_commands (ELEMENT *current, enum command_id closed_command,
                          ELEMENT **closed_element, enum command_id);
+ELEMENT *close_all_style_commands (ELEMENT *current,
+                               enum command_id closed_command,
+                               enum command_id interrupting_command);
 
 /* In end_line.c */
 NODE_SPEC_EXTRA *parse_node_manual (ELEMENT *node);
@@ -38,7 +41,9 @@
 extern size_t conditional_number;
 void parse_texi_file (const char *filename);
 int abort_empty_line (ELEMENT **current_inout, char *additional);
-ELEMENT *end_paragraph (ELEMENT *current);
+ELEMENT *end_paragraph (ELEMENT *current,
+                        enum command_id closed_command,
+                        enum command_id interrupting_command);
 void isolate_last_space (ELEMENT *current, enum element_type type);
 int command_with_command_as_argument (ELEMENT *current);
 ELEMENT *begin_preformatted (ELEMENT *current);

Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-12-03 16:27:37 UTC (rev 6831)
+++ trunk/parsetexi/separator.c 2015-12-03 18:26:22 UTC (rev 6832)
@@ -280,7 +280,7 @@
     {
       enum context c;
 
-      current = end_paragraph (current);
+      current = end_paragraph (current, 0, 0);
       if (1)
         {
           enum command_id closed_command;




reply via email to

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