[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp/Texinfo Parser.pm
From: |
Patrice Dumas |
Subject: |
texinfo/tp/Texinfo Parser.pm |
Date: |
Sat, 16 Oct 2010 09:36:21 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 10/10/16 09:36:21
Modified files:
tp/Texinfo : Parser.pm
Log message:
Add forgotten tieaccent.
New entry point to parse a whole file.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.68&r2=1.69
Patches:
Index: Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -b -r1.68 -r1.69
--- Parser.pm 14 Oct 2010 23:11:45 -0000 1.68
+++ Parser.pm 16 Oct 2010 09:36:21 -0000 1.69
@@ -40,9 +40,9 @@
parser
tree_to_texi
parse_texi_text
+ parse_texi_file
errors
) ] );
-# parse_file
@EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
@@ -221,7 +221,8 @@
$brace_commands{$accent_command} = 1;
}
-foreach my
$accent_command('ringaccent','H','dotaccent','u','ubaraccent','udotaccent','v','ogonek')
{
+foreach my $accent_command('ringaccent','H','dotaccent','u','ubaraccent',
+ 'udotaccent','v','ogonek','tieaccent') {
$accent_commands{$accent_command} = 1;
$brace_commands{$accent_command} = 1;
}
@@ -589,6 +590,34 @@
return $self->_internal_parse_text([{'pending' => $lines_array}]);
}
+sub parse_texi_file ($$)
+{
+ my $self = shift;
+ my $file_name = shift;
+ # FIXME error message
+ local *FILE;
+ open (*FILE, $file_name) or return undef;
+ my $line_nr = 0;
+ my $line;
+ my @first_lines;
+ while ($line = <FILE>) {
+ $line_nr++;
+ $line =~ s/\x{7F}.*\s*//;
+ if ($line =~ /^ *\\input/ or $line =~ /^\s*$/) {
+ push @first_lines, $line;
+ } else {
+ last;
+ }
+ }
+ return $self->_internal_parse_text([{
+ 'pending' => [ [$line, { 'line_nr' => $line_nr,
+ 'file_name' => $file_name, 'macro' => '' }] ],
+ 'name' => $file_name,
+ 'line_nr' => $line_nr,
+ 'fh' => \*FILE
+ }], address@hidden);
+}
+
sub tree_to_texi ($);
sub errors ($)
@@ -961,7 +990,8 @@
if (defined($line)) {
$current->{'line_nr'} ++;
return ($line, {'line_nr' => $current->{'line_nr'},
- 'file_name' => $current->{'name'}});
+ 'file_name' => $current->{'name'},
+ 'macro' => ''});
}
}
shift(@$input);
@@ -1384,10 +1414,16 @@
{
my $self = shift;
my $text = shift;
- my $no_para = shift;
+ my $first_lines = shift;
my $root = { 'contents' => [] };
my $current = $root;
+ if ($first_lines) {
+ foreach my $line (@$first_lines) {
+ push @{$current->{'contents'}}, { 'text' => $line,
+ 'type' => 'preamble' };
+ }
+ }
$self->{'conditionals_stack'} = [];
@@ -1807,19 +1843,21 @@
# REMACRO
if ($line =~ s/^\s+([[:alnum:]][[:alnum:]-]*)//) {
my $end_command = $1;
- print STDERR "END $end_command\n" if ($self->{'debug'});
if (!exists $block_commands{$end_command}) {
_line_warn ($self,
sprintf($self->__("Unknown address@hidden %s"), $end_command),
$line_nr);
$current = _merge_text ($self, $current, "address@hidden
$end_command");
last;
}
+ print STDERR "END BLOCK $end_command\n" if ($self->{'debug'});
if ($block_commands{$end_command} eq 'conditional') {
if (@{$self->{'conditionals_stack'}}
and $self->{'conditionals_stack'}->[-1] eq $end_command) {
pop @{$self->{'conditionals_stack'}};
# Ignore until end of line
+ if ($line !~ /\n/) {
($line, $line_nr) = _new_line($text, $line_nr);
+ }
} else {
_line_error ($self,
sprintf($self->__("Unmatched `%c%s'"),
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/04
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/04
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/09
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/14
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/14
- texinfo/tp/Texinfo Parser.pm,
Patrice Dumas <=
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/18
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/19
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/19
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/24
- texinfo/tp/Texinfo Parser.pm, Patrice Dumas, 2010/10/24