texinfo-commits
[Top][All Lists]
Advanced

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

[6837] parsetexi update


From: Gavin D. Smith
Subject: [6837] parsetexi update
Date: Sun, 06 Dec 2015 22:41:03 +0000

Revision: 6837
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=6837
Author:   gavin
Date:     2015-12-06 22:41:01 +0000 (Sun, 06 Dec 2015)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/Parsetexi/Parsetexi.xs
    trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
    trunk/parsetexi/api.c
    trunk/parsetexi/api.h
    trunk/parsetexi/context_stack.c
    trunk/parsetexi/context_stack.h
    trunk/parsetexi/indices.c
    trunk/parsetexi/input.c
    trunk/parsetexi/parser.c

Modified: trunk/parsetexi/Parsetexi/Parsetexi.xs
===================================================================
--- trunk/parsetexi/Parsetexi/Parsetexi.xs      2015-12-05 18:45:21 UTC (rev 
6836)
+++ trunk/parsetexi/Parsetexi/Parsetexi.xs      2015-12-06 22:41:01 UTC (rev 
6837)
@@ -67,6 +67,9 @@
 wipe_values ()
 
 void
+reset_context_stack ()
+
+void
 init_index_commands ()
 
 ELEMENT *

Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-12-05 18:45:21 UTC (rev 
6836)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2015-12-06 22:41:01 UTC (rev 
6837)
@@ -281,11 +281,11 @@
   if (1) {
     # This is our third way of passing the data: construct it using
     # Perl api directly.
-    print "Parsing file...\n";
+    #print "Parsing file...\n";
     parse_file ($file_name);
-    print "Fetching data..\n";
+    #print "Fetching data..\n";
     $TREE = build_texinfo_tree ();
-    print "Got tree...\n";
+    #print "Got tree...\n";
     #print Texinfo::Parser::_print_tree ($TREE);
 
     $LABELS = build_label_list ();
@@ -337,6 +337,47 @@
   _complete_node_list ($self, $TREE);
   print "Adjusted tree.\n";
 
+
+  # line 899
+  my $text_root;
+  if ($TREE->{'type'} eq 'text_root') {
+    $text_root = $TREE;
+  } elsif ($TREE->{'contents'} and $TREE->{'contents'}->[0]
+      and $TREE->{'contents'}->[0]->{'type'} eq 'text_root') {
+    $text_root = $TREE->{'contents'}->[0];
+  }
+
+  # Put everything before @setfilename in a special type.  This allows
+  # ignoring everything before @setfilename.
+
+  # The non-XS Perl code checks $self->{'extra'}->{'setfilename'}, which
+  # would be set in _register_global_command.
+  if ($self->{'IGNORE_BEFORE_SETFILENAME'} and $text_root) {
+    my $before_setfilename = {'type' => 'preamble_before_setfilename',
+      'parent' => $text_root,
+      'contents' => []};
+    while (@{$text_root->{'contents'}}
+        and (!$text_root->{'contents'}->[0]->{'cmdname'}
+          or $text_root->{'contents'}->[0]->{'cmdname'} ne 'setfilename')) {
+      my $content = shift @{$text_root->{'contents'}};
+      $content->{'parent'} = $before_setfilename;
+      push @{$before_setfilename->{'contents'}}, $content;
+    }
+    if (address@hidden>{'contents'}}) {
+      # not found
+      #splice @{$text_root->{'contents'}}, 0, 0, @$before_setfilename;
+      $text_root->{'contents'} = $before_setfilename;
+    }
+    else {
+    unshift (@{$text_root->{'contents'}}, $before_setfilename)
+      if (@{$before_setfilename->{'contents'}});
+    }
+  }
+
+
+
+  ############################################################
+
   $self->{'info'} = $GLOBAL_INFO;
   #print "!!! ENCODING IS ", $self->{'info'}->{'input_encoding_name'} , "\n";
 

Modified: trunk/parsetexi/api.c
===================================================================
--- trunk/parsetexi/api.c       2015-12-05 18:45:21 UTC (rev 6836)
+++ trunk/parsetexi/api.c       2015-12-06 22:41:01 UTC (rev 6837)
@@ -43,6 +43,7 @@
   debug_output = 0;
   init_index_commands ();
   wipe_errors ();
+  reset_context_stack ();
   parse_texi_file (filename);
 }
 
@@ -52,14 +53,22 @@
   return Root;
 }
 
+static void
+reset_parser ()
+{
+  init_index_commands ();
+  wipe_errors ();
+  reset_context_stack ();
+  current_node = current_section = 0;
+}
+
 /* Set ROOT to root of tree obtained by parsing the Texinfo code in STRING.
    Used for parse_texi_line. */
 void
 parse_string (char *string)
 {
   ELEMENT *root;
-  //init_index_commands (); /* FIXME - probably not necessary */
-  wipe_errors ();
+  reset_parser ();
   root = new_element (ET_root_line);
   input_push_text (strdup (string));
   Root = parse_texi (root);
@@ -70,8 +79,7 @@
 parse_text (char *string)
 {
   ELEMENT *root;
-  //init_index_commands (); /* FIXME - probably not necessary */
-  wipe_errors ();
+  reset_parser ();
   root = new_element (ET_text_root);
   input_push_text_with_line_nos (strdup (string));
   Root = parse_texi (root);
@@ -176,6 +184,7 @@
     }
 
   if (e->parent //) // && e->parent_type != route_not_in_tree)
+    && e->type != ET_preamble_text
     && e->type != ET_empty_spaces_before_argument) //FIXME :Set parent in
                                                    // perl code
     {

Modified: trunk/parsetexi/api.h
===================================================================
--- trunk/parsetexi/api.h       2015-12-05 18:45:21 UTC (rev 6836)
+++ trunk/parsetexi/api.h       2015-12-06 22:41:01 UTC (rev 6837)
@@ -22,3 +22,6 @@
 
 /* In indices.c */
 void init_index_commands (void);
+
+/* In api.c */
+void reset_context_stack (void);

Modified: trunk/parsetexi/context_stack.c
===================================================================
--- trunk/parsetexi/context_stack.c     2015-12-05 18:45:21 UTC (rev 6836)
+++ trunk/parsetexi/context_stack.c     2015-12-06 22:41:01 UTC (rev 6837)
@@ -16,13 +16,21 @@
 
 #include <stdlib.h>
 
+#include "tree_types.h"
 #include "context_stack.h"
+#include "api.h"
 
 static enum context *stack;
 static size_t top; /* One above last pushed context. */
 static size_t space;
 
 void
+reset_context_stack (void)
+{
+  top = 0;
+}
+
+void
 push_context (enum context c)
 {
   if (top >= space)

Modified: trunk/parsetexi/context_stack.h
===================================================================
--- trunk/parsetexi/context_stack.h     2015-12-05 18:45:21 UTC (rev 6836)
+++ trunk/parsetexi/context_stack.h     2015-12-06 22:41:01 UTC (rev 6837)
@@ -42,3 +42,4 @@
 enum context pop_context ();
 enum context current_context (void);
 
+void reset_context_stack (void);

Modified: trunk/parsetexi/indices.c
===================================================================
--- trunk/parsetexi/indices.c   2015-12-05 18:45:21 UTC (rev 6836)
+++ trunk/parsetexi/indices.c   2015-12-06 22:41:01 UTC (rev 6837)
@@ -146,6 +146,8 @@
   char name[] = "?index";
   char name2[] = "??index";
 
+  number_of_indices = 0;
+
 #define MAX (10 * 2)
 
 #define X(command) CM_##command, CM_##command##x

Modified: trunk/parsetexi/input.c
===================================================================
--- trunk/parsetexi/input.c     2015-12-05 18:45:21 UTC (rev 6836)
+++ trunk/parsetexi/input.c     2015-12-06 22:41:01 UTC (rev 6837)
@@ -136,10 +136,7 @@
               /* Strip off a comment. */
               comment = strchr (line, '\x7F');
               if (comment)
-                {
-                  *comment = '\n';
-                  comment[1] = '\0';
-                }
+                *comment = '\0';
 
               /* TODO: convert from @documentencoding to UTF-8, assuming we 
                  want to use UTF-8 internally. */

Modified: trunk/parsetexi/parser.c
===================================================================
--- trunk/parsetexi/parser.c    2015-12-05 18:45:21 UTC (rev 6836)
+++ trunk/parsetexi/parser.c    2015-12-06 22:41:01 UTC (rev 6837)
@@ -164,6 +164,8 @@
           /* This line is not part of the preamble.  Shove back
              into input stream. */
           input_push_text (line);
+          if (line_nr.line_nr > 0)
+            line_nr.line_nr--;
           break;
         }
 
@@ -271,8 +273,14 @@
       debug ("CLOSE PREFORMATTED %s",
              current->type == ET_preformatted ? "preformatted"
                                               : "rawpreformatted");
-      // remove if empty
-      current = current->parent;
+      if (current->contents.number == 0)
+        {
+          current = current->parent;
+          destroy_element (pop_element_from_contents (current));
+          debug ("popping");
+        }
+      else
+        current = current->parent;
     }
   return current;
 }




reply via email to

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