texinfo-commits
[Top][All Lists]
Advanced

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

[6822] parsetexi update


From: Gavin D. Smith
Subject: [6822] parsetexi update
Date: Tue, 01 Dec 2015 16:53:24 +0000

Revision: 6822
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6822
Author:   gavin
Date:     2015-12-01 16:53:23 +0000 (Tue, 01 Dec 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/api.c
    trunk/parsetexi/end_line.c
    trunk/parsetexi/input.c
    trunk/parsetexi/parser.c
    trunk/parsetexi/separator.c

Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c       2015-12-01 13:27:15 UTC (rev 6821)
+++ trunk/parsetexi/api.c       2015-12-01 16:53:23 UTC (rev 6822)
@@ -280,13 +280,18 @@
             case extra_element:
               /* For references to other parts of the tree, create the hash so 
                  we can point to it.  */
-              if (!f->hv && f->parent_type != route_not_in_tree)
+              if (!f->hv)
                 {
-                  /* TODO: Are there any extra values which are
-                     extra_element that are route_not_in_tree?  Consider
-                     eliminating use of 'parent_type' to differentiate types
-                     of extra value. */
-                  f->hv = newHV ();
+                  if (f->parent_type != route_not_in_tree)
+                    {
+                      /* TODO: Are there any extra values which are
+                         extra_element that are route_not_in_tree?  Consider
+                         eliminating use of 'parent_type' to differentiate 
types
+                         of extra value. */
+                      f->hv = newHV ();
+                    }
+                  else
+                    element_to_perl_hash (f);
                 }
               STORE(newRV_inc ((SV *)f->hv));
               break;
@@ -317,11 +322,15 @@
                     {
                       ELEMENT *h;
                       h = g->contents.list[k];
-                      /* TODO: Check if any of the elements in the array
-                         are not in the main tree - if so, we will have to
-                         create them. */
                       if (!h->hv)
-                        h->hv = newHV ();
+                        {
+                          if (h->parent_type != route_not_in_tree)
+                            h->hv = newHV ();
+                          else
+                            {
+                              element_to_perl_hash (h);
+                            }
+                        }
                       av_push (av2, newRV_inc ((SV*)h->hv));
                     }
                 }

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2015-12-01 13:27:15 UTC (rev 6821)
+++ trunk/parsetexi/end_line.c  2015-12-01 16:53:23 UTC (rev 6822)
@@ -888,7 +888,33 @@
 
       /* 3052 - if no command_as_argument given, default to @bullet for
          @itemize, and @asis for @table. */
+      if (current->cmd == CM_itemize
+        && !lookup_extra_key (current, "block_command_line_contents"))
+        {
+          ELEMENT *e, *contents, *contents2;
 
+          e = new_element (ET_command_as_argument);
+          e->cmd = CM_bullet;
+          e->parent_type = route_not_in_tree;
+          //e->parent = current; // FIXME: done in Perl code
+          add_extra_key_element (current, "command_as_argument", e);
+
+          contents = new_element (ET_NONE);
+          contents2 = new_element (ET_NONE);
+          contents2->parent_type = route_not_in_tree;
+          add_to_contents_as_array (contents2, e);
+          add_to_element_contents (contents, contents2);
+          add_extra_key_contents_array (current, "block_command_line_contents",
+                                        contents);
+        }
+      else if (item_line_command (current->cmd)
+          && !lookup_extra_key (current, "command_as_argument"))
+        {
+          ELEMENT *e = new_element (ET_command_as_argument);
+          e->cmd = CM_asis;
+          add_extra_key_element (current, "command_as_argument", e);
+        }
+
       {
         ELEMENT *bi = new_element (ET_before_item);
         add_to_element_contents (current, bi);
@@ -974,6 +1000,7 @@
         }
       else
         {
+          add_extra_string (current, "text_arg", text);
           if (current->cmd == CM_end) /* 3128 */
             {
               char *line = text;
@@ -1002,14 +1029,23 @@
 
                       if (command_data(end_id).data == BLOCK_conditional)
                         {
-                          if (conditional_number > 0)
+                          enum command_id popped;
+                          if (conditional_number == 0)
+                            goto conditional_stack_fail;
+                          popped = pop_conditional_stack ();
+                          if (popped != end_id)
                             {
-                              enum command_id popped;
-                              popped = pop_conditional_stack ();
-                              if (popped != end_id)
-                                abort ();
+                              push_conditional_stack (popped);
+                              goto conditional_stack_fail;
                             }
+                          if (0)
+                            {
+                          conditional_stack_fail:
+                              command_error ("unmatched @end");
+                            }
                         }
+                      add_extra_string (current, "command_argument",
+                                        strdup (end_command));
                     }
                 }
               else

Modified: trunk/parsetexi/input.c
===================================================================
--- trunk/parsetexi/input.c     2015-12-01 13:27:15 UTC (rev 6821)
+++ trunk/parsetexi/input.c     2015-12-01 16:53:23 UTC (rev 6822)
@@ -110,10 +110,11 @@
             i->ptext = p + 1;
           else
             i->ptext = p; /* The next time, we will pop the input source. */
+
+          if (line_nr.line_nr != -1)
+            line_nr.line_nr++;
+
           return new;
-
-          if (line_nr.line_nr != 0)
-              line_nr.line_nr++;
           // what if it doesn't end in a newline ?
 
           break;
@@ -216,7 +217,7 @@
 input_push_text_with_line_nos (char *text)
 {
   input_push_text (text);
-  line_nr.line_nr = 1;
+  line_nr.line_nr = 0;
   line_nr.file_name = 0;
 }
 

Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c    2015-12-01 13:27:15 UTC (rev 6821)
+++ trunk/parsetexi/parser.c    2015-12-01 16:53:23 UTC (rev 6822)
@@ -555,6 +555,8 @@
 
 /* Parts of parse_texi lines 3676 - 5372 */
 
+/* If the parent element takes a command as an argument, like
+   @itemize @bullet. */
 int
 command_with_command_as_argument (ELEMENT *current)
 {

Modified: trunk/parsetexi/separator.c
===================================================================
--- trunk/parsetexi/separator.c 2015-12-01 13:27:15 UTC (rev 6821)
+++ trunk/parsetexi/separator.c 2015-12-01 16:53:23 UTC (rev 6822)
@@ -37,6 +37,13 @@
   ELEMENT *new;
   KEY_PAIR *k;
 
+  new = trim_spaces_comment_from_content (current);
+  if (new->contents.number == 0)
+    {
+      free (new);
+      return;
+    }
+
   /* FIXME: Could we add all the command args together, instead of one-by-one,
      to avoid having to look for the extra value every time? */
   k = lookup_extra_key (current->parent, key);
@@ -49,8 +56,6 @@
       add_extra_key_contents_array (current->parent, key, value);
     }
 
-  new = trim_spaces_comment_from_content (current);
-
   add_to_contents_as_array (value, new);
 }
 




reply via email to

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