texinfo-commits
[Top][All Lists]
Advanced

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

[7183] parsetexi region stack


From: gavinsmith0123
Subject: [7183] parsetexi region stack
Date: Wed, 25 May 2016 18:29:16 +0000 (UTC)

Revision: 7183
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7183
Author:   gavin
Date:     2016-05-25 18:29:16 +0000 (Wed, 25 May 2016)
Log Message:
-----------
parsetexi region stack

Modified Paths:
--------------
    trunk/tp/parsetexi/ChangeLog
    trunk/tp/parsetexi/api.c
    trunk/tp/parsetexi/close.c
    trunk/tp/parsetexi/command_data.txt
    trunk/tp/parsetexi/context_stack.c
    trunk/tp/parsetexi/context_stack.h
    trunk/tp/parsetexi/handle_commands.c
    trunk/tp/parsetexi/indices.c

Modified: trunk/tp/parsetexi/ChangeLog
===================================================================
--- trunk/tp/parsetexi/ChangeLog        2016-05-24 20:21:09 UTC (rev 7182)
+++ trunk/tp/parsetexi/ChangeLog        2016-05-25 18:29:16 UTC (rev 7183)
@@ -1,3 +1,7 @@
+2016-05-25  Gavin Smith  <address@hidden>
+
+       * context_stack.c: Implement region stack.
+
 2016-05-22  Gavin Smith  <address@hidden>
 
        * parser.c (mark_and_warn_invalid): Implement.

Modified: trunk/tp/parsetexi/api.c
===================================================================
--- trunk/tp/parsetexi/api.c    2016-05-24 20:21:09 UTC (rev 7182)
+++ trunk/tp/parsetexi/api.c    2016-05-25 18:29:16 UTC (rev 7183)
@@ -51,10 +51,9 @@
   init_index_commands ();
   wipe_errors ();
   reset_context_stack ();
+  reset_region_stack ();
   reset_floats ();
   clear_expanded_formats ();
-  //add_expanded_format ("plaintext");
-  //add_expanded_format ("info");
 
   current_node = current_section = 0;
 }
@@ -705,6 +704,11 @@
       STORE2("command",
              newRV_inc ((SV *)e->command->hv));
       STORE2("number", newSViv (j + 1));
+      if (e->region)
+        {
+          STORE2("region",
+                 newSVpv (command_name(e->region), 0));
+        }
       if (e->content)
         {
           SV **contents_array;

Modified: trunk/tp/parsetexi/close.c
===================================================================
--- trunk/tp/parsetexi/close.c  2016-05-24 20:21:09 UTC (rev 7182)
+++ trunk/tp/parsetexi/close.c  2016-05-25 18:29:16 UTC (rev 7183)
@@ -296,6 +296,10 @@
             {
               pop_context ();
             }
+          if (command_data(cmd).flags & CF_region)
+            {
+              pop_region ();
+            }
           if (!parent)
             parent = current->parent;
           current = parent;
@@ -402,7 +406,10 @@
             abort ();
         }
 
-      // 1784 maybe pop regions stack
+      // 1784
+      if (command_data(current->cmd).flags & CF_region)
+        pop_region ();
+
       *closed_element = current;
       current = current->parent; /* 1788 */
     }

Modified: trunk/tp/parsetexi/command_data.txt
===================================================================
--- trunk/tp/parsetexi/command_data.txt 2016-05-24 20:21:09 UTC (rev 7182)
+++ trunk/tp/parsetexi/command_data.txt 2016-05-25 18:29:16 UTC (rev 7183)
@@ -420,9 +420,9 @@
 smallindentedblock     block
 
 # region commands
-titlepage              block,global_unique
-copying                        block,global_unique
-documentdescription    block,global_unique
+titlepage              block,global_unique,region
+copying                        block,global_unique,region
+documentdescription    block,global_unique,region
 
 # preformatted commands
 example                        block,preformatted,preformatted_code

Modified: trunk/tp/parsetexi/context_stack.c
===================================================================
--- trunk/tp/parsetexi/context_stack.c  2016-05-24 20:21:09 UTC (rev 7182)
+++ trunk/tp/parsetexi/context_stack.c  2016-05-25 18:29:16 UTC (rev 7183)
@@ -65,3 +65,49 @@
 
   return stack[top - 1];
 }
+
+
+/* the valid regions are 'titlepage', 'copying', and 'documentdescription' */
+
+static enum command_id *region_stack;
+static size_t region_top; /* One above last pushed region. */
+static size_t region_space;
+
+void
+reset_region_stack (void)
+{
+  region_top = 0;
+}
+
+void
+push_region (enum command_id r)
+{
+  if (region_top >= region_space)
+    {
+      region_stack = realloc (region_stack,
+                              (region_space += 5) * sizeof (enum command_id));
+    }
+
+  debug (">>>>>>>>>>>>>>>>>PUSHING REGION STACK AT %d", region_top);
+
+  region_stack[region_top++] = r;
+}
+
+enum command_id
+pop_region ()
+{
+  if (region_top == 0)
+    abort ();
+
+  debug (">>>>>>>>>>>>>POPPING REGION STACK AT %d", region_top - 1);
+  return region_stack[--region_top];
+}
+
+enum command_id
+current_region (void)
+{
+  if (region_top == 0)
+    return CM_NONE;
+
+  return region_stack[region_top - 1];
+}

Modified: trunk/tp/parsetexi/context_stack.h
===================================================================
--- trunk/tp/parsetexi/context_stack.h  2016-05-24 20:21:09 UTC (rev 7182)
+++ trunk/tp/parsetexi/context_stack.h  2016-05-25 18:29:16 UTC (rev 7183)
@@ -41,5 +41,11 @@
 void push_context (enum context c);
 enum context pop_context ();
 enum context current_context (void);
+void reset_context_stack (void);
 
-void reset_context_stack (void);
+
+void push_region (enum command_id r);
+enum command_id pop_region ();
+enum command_id current_region (void);
+
+void reset_region_stack (void);

Modified: trunk/tp/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/parsetexi/handle_commands.c        2016-05-24 20:21:09 UTC (rev 
7182)
+++ trunk/tp/parsetexi/handle_commands.c        2016-05-25 18:29:16 UTC (rev 
7183)
@@ -937,7 +937,17 @@
               push_context (ct_rawpreformatted);
             }
 
-          // regionsstack
+          // 4775
+          if (command_data(cmd).flags & CF_region)
+            {
+              if (current_region ())
+                {
+                  line_error ("region %s inside region %s is not allowed",
+                              command_name(cmd),
+                              command_name(current_region ()));
+                }
+              push_region (cmd);
+            }
 
           // 4784 menu commands
           if (command_data(cmd).flags & CF_menu)

Modified: trunk/tp/parsetexi/indices.c
===================================================================
--- trunk/tp/parsetexi/indices.c        2016-05-24 20:21:09 UTC (rev 7182)
+++ trunk/tp/parsetexi/indices.c        2016-05-25 18:29:16 UTC (rev 7183)
@@ -263,6 +263,8 @@
   entry->command = current;
   entry->number = idx->index_number;
 
+  if (current_region ())
+    entry->region = current_region ();
   entry->node = current_node;
 
   entry->number = idx->index_number;
@@ -273,9 +275,7 @@
 
   add_extra_index_entry (current, "index_entry", ier);
 
-  if (current_node)
-    ; // TODO
-  else if (!current_section)
+  if (!current_node && !current_section)
     line_warn ("entry for index `%s' outside of any node", idx->name);
 }
 




reply via email to

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