texinfo-commits
[Top][All Lists]
Advanced

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

[5963] parsetexi update


From: Gavin D. Smith
Subject: [5963] parsetexi update
Date: Sun, 14 Dec 2014 17:36:51 +0000

Revision: 5963
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5963
Author:   gavin
Date:     2014-12-14 17:36:49 +0000 (Sun, 14 Dec 2014)
Log Message:
-----------
parsetexi update

Modified Paths:
--------------
    trunk/parsetexi/ChangeLog
    trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
    trunk/parsetexi/TODO
    trunk/parsetexi/dump_perl.c
    trunk/parsetexi/end_line.c
    trunk/parsetexi/makeinfo
    trunk/parsetexi/tree_types.h

Modified: trunk/parsetexi/ChangeLog
===================================================================
--- trunk/parsetexi/ChangeLog   2014-12-14 02:45:35 UTC (rev 5962)
+++ trunk/parsetexi/ChangeLog   2014-12-14 17:36:49 UTC (rev 5963)
@@ -1,5 +1,18 @@
 2014-12-14  Gavin Smith  <address@hidden>
 
+       * Parsetexi/lib/Parsetexi.pm: Put Texinfo::Report in @ISA.
+       (parser): Set 'gettext' on parser object.
+
+       * tree_types.h (enum route_element_type): New value 
+       route_not_in_tree.
+       * dump_perl.c (dump_extra): If extra key marked as not in tree, 
+       dump it in the main tree output.
+       * end_line.c (@node): Create a new element with some whitespace 
+       elements removed from its contents, and save this as 
+       "node_content".
+
+2014-12-14  Gavin Smith  <address@hidden>
+
        * parser.c (current_node, current_section): New variables.
        * end_line.c (end_line) <@node>: Set current_node.
        <root commands>: Set 'associated_node' and 'associated_section' 

Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2014-12-14 02:45:35 UTC (rev 
5962)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm  2014-12-14 17:36:49 UTC (rev 
5963)
@@ -8,7 +8,7 @@
 require Exporter;
 use AutoLoader;
 
-our @ISA = qw(Exporter);
+our @ISA = qw(Exporter Texinfo::Report);
 
 # Items to export into callers namespace by default. Note: do not export
 # names by default without a very good reason. Use EXPORT_OK instead.
@@ -28,7 +28,6 @@
   labels_information
   global_commands_information
   global_informations
-  errors
 ) ] );
 
 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@@ -94,7 +93,12 @@
   'USE_UP_NODE_FOR_ELEMENT_UP' => 0, # Use node up for Up if there is no 
                                     # section up.
 );
+  
+my %parser_default_configuration =
+  (%Texinfo::Common::default_parser_state_configuration,
+   %default_customization_values);
 
+
 # Stub for Texinfo::Parser::parser (line 574)
 sub parser (;$$)
 {
@@ -123,8 +127,13 @@
 
   my $parser = \%parser_hash;
 
+  $parser->{'gettext'} = $parser_default_configuration{'gettext'};
+  $parser->{'pgettext'} = $parser_default_configuration{'pgettext'};
+
   bless $parser;
 
+  $parser->Texinfo::Report::new;
+
   return $parser;
 }
 
@@ -228,7 +237,7 @@
   #$Data::Dumper::Indent = 1;
   #my $bar = Data::Dumper->Dump([$VAR1], ['$VAR1']);
   #print $bar;
-  
+
   return $VAR1;
 }
 
@@ -269,15 +278,7 @@
   return $self->{'labels'};
 }
 
-################ Stubs for Texinfo::Report ########################
-#
 
-# Report.pm:54
-sub errors ($)
-{
-  return ([], 0);
-}
-
 # Preloaded methods go here.
 
 # Autoload methods go after =cut, and are processed by the autosplit program.

Modified: trunk/parsetexi/TODO
===================================================================
--- trunk/parsetexi/TODO        2014-12-14 02:45:35 UTC (rev 5962)
+++ trunk/parsetexi/TODO        2014-12-14 17:36:49 UTC (rev 5963)
@@ -1,9 +1,12 @@
-* Add a way to serialize extra keys, indices_information, etc.  This will 
-allow integration with makeinfo, "hello world", which will then greatly 
-ease testing that the produced parse tree is what the backends require.
+* Add a way to serialize labels_information, indices_information, etc., 
+to ease testing that the produced parse tree is what the backends 
+require.
 
 * Convert makeinfo backends to use a Perl stub for the C API. The C parser 
 will not be used at this point.
 
 * Substitute the XS API implementation for the Perl API when the C parser is 
 good enough.
+
+Other tasks -
+* implement node name normalization output converter

Modified: trunk/parsetexi/dump_perl.c
===================================================================
--- trunk/parsetexi/dump_perl.c 2014-12-14 02:45:35 UTC (rev 5962)
+++ trunk/parsetexi/dump_perl.c 2014-12-14 17:36:49 UTC (rev 5963)
@@ -16,6 +16,7 @@
 
 void dump_contents (ELEMENT *);
 void dump_element (ELEMENT *);
+void dump_args (ELEMENT *);
 
 /* Output INDENT spaces. */
 void
@@ -142,28 +143,47 @@
       for (i = 0; i < e->extra_number; i++)
         {
           dump_indent ();
-          printf ("'%s' => {},\n", e->extra[i].key);
 
-          if (e->extra[i].value->parent_type != route_uninitialized)
+          if (e->extra[i].value->parent_type == route_not_in_tree)
             {
-              dump_fixup_line (e, i);
+              switch (e->extra[i].type)
+                {
+                case extra_element:
+                  dump_element (e->extra[i].value);
+                  break;
+                case extra_element_contents:
+                  printf ("'%s' => ", e->extra[i].key);
+                  dump_contents (e->extra[i].value);
+                  break;
+                default:
+                  abort ();
+                }
             }
-          else /* Add a pending reference to this element. */
+          else
             {
-              ELEMENT *e2;
+              printf ("'%s' => {},\n", e->extra[i].key);
 
-              e2 = e->extra[i].value;
-
-              if (e2->pending_number == e2->pending_space)
+              if (e->extra[i].value->parent_type != route_uninitialized)
                 {
-                  e2->pending_references = realloc (e2->pending_references,
-                      (e2->pending_space += 2) * sizeof (PENDING_REFERENCE));
-                  if (!e2->pending_references)
-                    abort ();
+                  dump_fixup_line (e, i);
                 }
+              else /* Add a pending reference to this element. */
+                {
+                  ELEMENT *e2;
 
-              e2->pending_references[e2->pending_number].element = e;
-              e2->pending_references[e2->pending_number++].extra_index = i;
+                  e2 = e->extra[i].value;
+
+                  if (e2->pending_number == e2->pending_space)
+                    {
+                      e2->pending_references = realloc (e2->pending_references,
+                        (e2->pending_space += 2) * sizeof (PENDING_REFERENCE));
+                      if (!e2->pending_references)
+                        abort ();
+                    }
+
+                  e2->pending_references[e2->pending_number].element = e;
+                  e2->pending_references[e2->pending_number++].extra_index = i;
+                }
             }
         }
     }
@@ -233,18 +253,18 @@
       dump_args (e);
     }
 
-  if (e->contents.number > 0)
+  if (e->extra_number > 0)
     {
       dump_indent ();
-      printf ("'contents' => ");
-      dump_contents (e);
+      printf ("'extra' => ");
+      dump_extra (e);
     }
 
-  if (e->extra_number > 0)
+  if (e->contents.number > 0)
     {
       dump_indent ();
-      printf ("'extra' => ");
-      dump_extra (e);
+      printf ("'contents' => ");
+      dump_contents (e);
     }
 
   indent -= 2;

Modified: trunk/parsetexi/end_line.c
===================================================================
--- trunk/parsetexi/end_line.c  2014-12-14 02:45:35 UTC (rev 5962)
+++ trunk/parsetexi/end_line.c  2014-12-14 17:36:49 UTC (rev 5963)
@@ -241,7 +241,6 @@
                             }
                         }
                     }
-
                 }
               else if (current->cmd == CM_include) /* 3166 */
                 {
@@ -262,19 +261,34 @@
         {
           int i;
           ELEMENT *arg;
+          ELEMENT *first_arg;
           /* Construct 'nodes_manuals' array.  This would be an 'extra' 
              reference to an array that doesn't exist anywhere else. */
 
           /* This sets the 'node_content' and 'normalized' keys on each 
element 
              in 'nodes_manuals'. */
           //parse_node_manual ();
-
           
-          /* Look for first non-empty argument. */
           /* In Perl a copy of the argument list is taken and the empty space 
              arguments are removed with trim_spaces_comment_from_content. */
-          add_extra_key_contents (current, "node_content",
-                                  current->args.list[0]);
+          first_arg = current->args.list[0];
+          arg = new_element (ET_NONE);
+          arg->parent_type = route_not_in_tree;
+          for (i = 0; i < first_arg->contents.number; i++)
+            {
+              if (first_arg->contents.list[i]->type
+                    != ET_empty_spaces_after_command
+                  && first_arg->contents.list[i]->type != ET_spaces_at_end)
+                {
+                  /* FIXME: Is this safe to serialize? */
+                  /* For example, if there are extra keys in the elements 
under 
+                     each argument?  They may not be set in a copy.
+                     Hopefully there aren't many extra keys set on commands in 
+                     node names. */
+                  add_to_element_contents (arg, first_arg->contents.list[i]);
+                }
+            }
+          add_extra_key_contents (current, "node_content", arg);
 
           /* Also set 'normalized' here.  The normalized labels are actually 
              the keys of "labels_information($parser)". */

Modified: trunk/parsetexi/makeinfo
===================================================================
--- trunk/parsetexi/makeinfo    2014-12-14 02:45:35 UTC (rev 5962)
+++ trunk/parsetexi/makeinfo    2014-12-14 17:36:49 UTC (rev 5963)
@@ -1,7 +1,7 @@
 #! /usr/bin/env bash
 
 #DEBUG='perl -d'
-#OPTIONS='-c DEBUG=1'
+OPTIONS='-c DEBUG=1 --no-validate'
 COMMAND=${COMMAND:-./texi2any-C.pl}
 
 
PERL5LIB=../tp:../tp/maintain/lib/libintl-perl/lib:../tp/maintain/lib/Text-Unidecode/lib/:../tp/maintain/lib/Unicode-EastAsianWidth/lib:./Parsetexi/lib:./Parsetexi/blib/lib:./Parsetexi/blib/arch/auto/Parsetexi
 ${DEBUG} ${COMMAND} ${OPTIONS} "$@"

Modified: trunk/parsetexi/tree_types.h
===================================================================
--- trunk/parsetexi/tree_types.h        2014-12-14 02:45:35 UTC (rev 5962)
+++ trunk/parsetexi/tree_types.h        2014-12-14 17:36:49 UTC (rev 5963)
@@ -30,7 +30,8 @@
 } LINE_NR;
 
 /* Type of a link in the route from the root of the tree to an element. */
-enum route_element_type { route_uninitialized, route_contents, route_args };
+enum route_element_type { route_uninitialized, route_contents, route_args,
+    route_not_in_tree };
 
 typedef struct {
     /* Element that contains a reference to this one. */




reply via email to

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