[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[5956] parsetexi update
From: |
Gavin D. Smith |
Subject: |
[5956] parsetexi update |
Date: |
Thu, 11 Dec 2014 20:22:44 +0000 |
Revision: 5956
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=5956
Author: gavin
Date: 2014-12-11 20:22:42 +0000 (Thu, 11 Dec 2014)
Log Message:
-----------
parsetexi update
Modified Paths:
--------------
trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
trunk/parsetexi/makeinfo
Added Paths:
-----------
trunk/parsetexi/test-files/
trunk/parsetexi/test-files/hello.texi
Modified: trunk/parsetexi/Parsetexi/lib/Parsetexi.pm
===================================================================
--- trunk/parsetexi/Parsetexi/lib/Parsetexi.pm 2014-12-11 16:56:28 UTC (rev
5955)
+++ trunk/parsetexi/Parsetexi/lib/Parsetexi.pm 2014-12-11 20:22:42 UTC (rev
5956)
@@ -65,11 +65,41 @@
require XSLoader;
XSLoader::load('Parsetexi', $VERSION);
+# Copied from Parser.pm
+# Customization variables obeyed by the Parser, and the default values.
+our %default_customization_values = (
+ 'TEST' => 0,
+ 'DEBUG' => 0, # if >= 10, tree is printed in texi2any.pl after parsing.
+ # If >= 100 tree is printed every line.
+ 'SHOW_MENU' => 1, # if false no menu error related.
+ 'INLINE_INSERTCOPYING' => 0,
+ 'IGNORE_BEFORE_SETFILENAME' => 1,
+ 'MACRO_BODY_IGNORES_LEADING_SPACE' => 0,
+ 'IGNORE_SPACE_AFTER_BRACED_COMMAND_NAME' => 1,
+ 'INPUT_PERL_ENCODING' => undef, # input perl encoding name, set from
+ # @documentencoding in the default case
+ 'INPUT_ENCODING_NAME' => undef, # encoding name normalized as preferred
+ # IANA, set from @documentencoding in the default
+ # case
+ 'CPP_LINE_DIRECTIVES' => 1, # handle cpp like synchronization lines
+ 'MAX_MACRO_CALL_NESTING' => 100000, # max number of nested macro calls
+ 'GLOBAL_COMMANDS' => [], # list of commands registered
+ # This is not used directly, but passed to Convert::Text through
+ # Texinfo::Common::_convert_text_options
+ 'ENABLE_ENCODING' => 1, # output accented and special characters
+ # based on @documentencoding
+ # following are used in Texinfo::Structuring
+ 'TOP_NODE_UP' => '(dir)', # up node of Top node
+ 'SIMPLE_MENU' => 0, # not used in the parser but in structuring
+ 'USE_UP_NODE_FOR_ELEMENT_UP' => 0, # Use node up for Up if there is no
+ # section up.
+);
+
# Stub for Texinfo::Parser::parser (line 574)
sub parser (;$$)
{
# None of these are implemented yet.
- my $parser = {
+ my %parser_blanks = (
'labels' => {},
'floats' => {},
'internal_references' => [],
@@ -77,13 +107,41 @@
'info' => {},
'index_names' => {},
'merged_indices' => {},
- };
+ 'nodes' => [],
+ # Not used but present in case we pass the object into
+ # Texinfo::Parser.
+ 'conditionals_stack' => [],
+ 'expanded_formats_stack' => [],
+ 'context_stack' => ['_root'],
+
+ );
+
+ my %parser_hash = %parser_blanks;
+ @parser_hash {keys %default_customization_values} =
+ values %default_customization_values;
+
+ my $parser = \%parser_hash;
+
bless $parser;
return $parser;
}
+use Texinfo::Parser;
+
+# Wrapper for Parser.pm:_parse_texi. We don't want to use this for the
+# main tree, but it is called via some other functions like
+# parse_texi_line, which is used in a few places. This stub should go
+# away at some point.
+sub _parse_texi ($;$)
+{
+ my $self = shift;
+ my $root = shift;
+
+ return Texinfo::Parser::_parse_texi ($self, $root);
+}
+
use Data::Dumper;
sub _add_parents ($);
@@ -106,6 +164,39 @@
}
}
+# Loop through the top-level elements in the tree, collecting node
+# elements into $ROOT->{'nodes'). This is used in
+# Structuring.pm:nodes_tree.
+sub _complete_node_list ($$) {
+ my $self = shift;
+ my $root = shift;
+
+ foreach my $child (@{$root->{'contents'}}) {
+ if ($child->{'cmdname'} and $child->{'cmdname'} eq 'node') {
+ #printf "FOUND NODE\n";
+ push $self->{'nodes'}, $child;
+ #print "CONTENTS are " . $child->{'contents'};
+
+ # TODO - actually normalize the name
+ $child->{'extra'}->{'normalized'} =
+ $child->{'args'}->[0]->{'contents'}->[1]->{'text'};
+
+ #print "Normalized node name saved as " .
+ #$child->{'extra'}->{'normalized'} . "\n";
+
+ $child->{'extra'}->{'nodes_manuals'} = [];
+ foreach my $node_arg (@{$child->{'args'}}) {
+ if (!defined($child->{'type'})
+ or ($child->{'type'} ne 'empty_spaces_after_command'
+ and $child->{'type'} ne 'spaces_at_end')) {
+ push $child->{'extra'}->{'nodes_manuals'},
+ {'node_content' => $node_arg->{'contents'}};
+ }
+ }
+ }
+ }
+}
+
# Stub for Texinfo::Parser::parse_texi_file (line 835)
sub parse_texi_file ($$)
{
@@ -127,6 +218,7 @@
#print "Adjusting tree...\n";
_add_parents ($VAR1);
+ _complete_node_list ($self, $VAR1);
#print "Adjusted tree.\n";
#$Data::Dumper::Purity = 1;
Modified: trunk/parsetexi/makeinfo
===================================================================
--- trunk/parsetexi/makeinfo 2014-12-11 16:56:28 UTC (rev 5955)
+++ trunk/parsetexi/makeinfo 2014-12-11 20:22:42 UTC (rev 5956)
@@ -1,3 +1,5 @@
#! /usr/bin/env bash
-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
./texi2any-C.pl "$@"
+#DEBUG=perl -d
+
+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} ./texi2any-C.pl "$@"
Added: trunk/parsetexi/test-files/hello.texi
===================================================================
--- trunk/parsetexi/test-files/hello.texi (rev 0)
+++ trunk/parsetexi/test-files/hello.texi 2014-12-11 20:22:42 UTC (rev
5956)
@@ -0,0 +1,31 @@
+\input texinfo @c -*-texinfo-*-
address@hidden %**start of header
address@hidden sample.info
address@hidden Sample Manual 1.0
address@hidden %**end of header
+
address@hidden
+This is a short example of a complete Texinfo file.
+
+Copyright @copyright{} 2014 Free Software Foundation, Inc.
address@hidden copying
+
address@hidden
address@hidden Sample Title
address@hidden
address@hidden 0pt plus 1filll
address@hidden
address@hidden titlepage
+
address@hidden Output the table of the contents at the beginning.
address@hidden
+
address@hidden
address@hidden Top
address@hidden GNU Sample
+
+This manual is for GNU Sample
address@hidden ifnottex
+
address@hidden
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [5956] parsetexi update,
Gavin D. Smith <=