[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
texinfo/tp Texinfo/Parser.pm t/03coverage_brace...
From: |
Patrice Dumas |
Subject: |
texinfo/tp Texinfo/Parser.pm t/03coverage_brace... |
Date: |
Mon, 04 Oct 2010 22:10:55 +0000 |
CVSROOT: /sources/texinfo
Module name: texinfo
Changes by: Patrice Dumas <pertusus> 10/10/04 22:10:54
Modified files:
tp/Texinfo : Parser.pm
tp/t : 03coverage_braces.t
Added files:
tp/t/results/coverage_braces: no_brace.pl
Log message:
Don't look forward for @-commands with brace opening braces, but
process it
as it comes.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/Texinfo/Parser.pm?cvsroot=texinfo&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/03coverage_braces.t?cvsroot=texinfo&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/texinfo/tp/t/results/coverage_braces/no_brace.pl?cvsroot=texinfo&rev=1.1
Patches:
Index: Texinfo/Parser.pm
===================================================================
RCS file: /sources/texinfo/texinfo/tp/Texinfo/Parser.pm,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- Texinfo/Parser.pm 4 Oct 2010 07:02:40 -0000 1.41
+++ Texinfo/Parser.pm 4 Oct 2010 22:10:54 -0000 1.42
@@ -337,7 +337,6 @@
unless ($block_command_one_arg =~ /quotation/);
}
-
$block_commands{'float'} = 2;
my %item_container_commands;
@@ -1193,10 +1192,22 @@
last;
}
}
- $line =~ s/^([^{}@,:\t.]*)//;
- $current = _merge_text ($self, $current, $1) if ($1 ne '');
+
+ if ($current->{'cmdname'} and
+ (defined($brace_commands{$current->{'cmdname'}}) or
+ $self->{'definfoenclose'}->{$current->{'cmdname'}})
+ and $line !~ /^{/) {
+ _line_error ($self,
+ sprintf($self->__("address@hidden expected braces"),
+ $current->{'cmdname'}), $line_nr);
+ $current = $current->{'parent'};
+ }
+ if ($line =~ s/^([^{}@,:\t.]+)//) {
+ my $new_text = $1;
+ $current = _merge_text ($self, $current, $new_text);
+
# REMACRO
- if ($line =~ s/^\@(["'address@hidden,\.!\?\s\*\-\^`=:\|\/\\])//o
+ } elsif ($line =~ s/^\@(["'address@hidden,\.!\?\s\*\-\^`=:\|\/\\])//o
or $line =~ s/^\@(\w[\w-]*)//o) {
my $command = $1;
$command = $self->{'aliases'}->{$command}
@@ -1515,46 +1526,12 @@
last unless ($line =~ /\S/);
}
}
- } elsif ($line =~ s/^{// and (defined($brace_commands{$command})
- or defined($self->{'definfoenclose'}->{$command}))) {
- #} elsif (defined($brace_commands{$command})
- # or defined($self->{'definfoenclose'}->{$command})) {
- push @{$current->{'contents'}}, { 'cmdname' => $command,
- 'parent' => $current,
- 'contents' => [] };
- $current = $current->{'contents'}->[-1];
- if ($command eq 'verb') {
- if ($line =~ /^$/) {
- $current->{'type'} = '';
- _line_error ($self, sprintf($self->
- __("address@hidden without associated character"), $command),
$line_nr);
- } else {
- $line =~ s/^(.)//;
- $current->{'type'} = $1;
- }
- }
- $current->{'args'} = [ { 'parent' => $current,
- 'contents' => [] } ];
- $current->{'remaining_args'} = $brace_commands{$command} -1
- if ($brace_commands{$command});
- if ($self->{'definfoenclose'}->{$command}) {
- $current->{'type'} = 'definfoenclose_command';
- $current->{'special'} = {
- 'begin' => $self->{'definfoenclose'}->{$command}->[0],
- 'end' => $self->{'definfoenclose'}->{$command}->[1] };
- $current->{'remaining_args'} = 0;
- }
- $current = $current->{'args'}->[-1];
- # FIXME don't use type to distinguish context_brace_commands.
- if ($context_brace_commands{$command}) {
- push @{$self->{'context_stack'}}, $command;
- } else {
- $current->{'type'} = 'brace_command_arg';
- }
- print STDERR "OPENED address@hidden>{'parent'}->{'cmdname'},
remaining: $current->{'parent'}->{'remaining_args'}, "
- .($current->{'type'} ? "type: $current->{'type'}" : '')."\n"
- if ($self->{'debug'});
- } elsif ($accent_commands{$command}) {
+ #} elsif ($line =~ s/^{// and (defined($brace_commands{$command})
+ # or defined($self->{'definfoenclose'}->{$command}))) {
+ } elsif (defined($brace_commands{$command})
+ or defined($self->{'definfoenclose'}->{$command})) {
+
+ if ($accent_commands{$command} and $line !~ /^{/) {
if ($command =~ /^[a-zA-Z]/) {
$line =~ s/^\s*//;
} elsif ($line =~ /^\s/) {
@@ -1562,7 +1539,6 @@
__("Accent command address@hidden' must not be followed by
whitespace"),
$command), $line_nr);
}
-
if ($line =~ /^\@/) {
_line_error ($self, sprintf($self->
__("Use braces to give a command as an argument to
address@hidden"),
@@ -1585,26 +1561,42 @@
push @{$current->{'contents'}},
{ 'text' => $command, 'parent' => $current };
}
- } elsif ($no_brace_commands{$command}) {
- push @{$current->{'contents'}},
- { 'cmdname' => $command, 'parent' => $current };
+ next;
+ }
- } elsif(exists $brace_commands{$command}) {
# special case of a command as argument of *table or itemize
- if ($current->{'parent'} and
+ if ($current->{'parent'} and $current->{'parent'}->{'cmdname'} and
($current->{'parent'}->{'cmdname'} eq 'itemize'
- or $block_item_commands{$current->{'parent'}->{'cmdname'}})
- and (scalar(@{$current->{'contents'}}) == 0)) {
+ or $item_line_commands{$current->{'parent'}->{'cmdname'}})
+ and (scalar(@{$current->{'contents'}}) == 0)
+ and $line !~ /^{/) {
push @{$current->{'contents'}}, {'cmdname' => $command,
'parent' => $current,
'type' => 'command_as_argument'};
} else {
- _line_error ($self,
- sprintf($self->__("address@hidden expected braces"), $command),
$line_nr);
+ push @{$current->{'contents'}}, { 'cmdname' => $command,
+ 'parent' => $current,
+ 'contents' => [] };
+ $current = $current->{'contents'}->[-1];
+ if ($self->{'definfoenclose'}->{$command}) {
+ $current->{'type'} = 'definfoenclose_command';
+ $current->{'special'} = {
+ 'begin' => $self->{'definfoenclose'}->{$command}->[0],
+ 'end' => $self->{'definfoenclose'}->{$command}->[1] };
}
- } elsif (defined($self->{'definfoenclose'}->{$command})) {
- _line_error ($self, sprintf($self->__("%c%s expected braces"),
- ord('@'), $command), $line_nr);
+ }
+ } elsif ($no_brace_commands{$command}) {
+ push @{$current->{'contents'}},
+ { 'cmdname' => $command, 'parent' => $current };
+
+ #} elsif(exists $brace_commands{$command}) {
+ # } else {
+ # _line_error ($self,
+ # sprintf($self->__("address@hidden expected braces"),
$command), $line_nr);
+ # }
+ #} elsif (defined($self->{'definfoenclose'}->{$command})) {
+ # _line_error ($self, sprintf($self->__("%c%s expected braces"),
+ # ord('@'), $command), $line_nr);
} else {
_line_error ($self, sprintf($self->__("Unknown command `%s'"),
$command), $line_nr);
@@ -1616,7 +1608,38 @@
if ($separator eq '@') {
_line_error ($self, $self->__("Unexpected \@"), $line_nr);
} elsif ($separator eq '{') {
- if ($current->{'parent'}
+ if ($current->{'cmdname'}
+ and (defined($brace_commands{$current->{'cmdname'}})
+ or $self->{'definfoenclose'}->{$current->{'cmdname'}})) {
+ my $command = $current->{'cmdname'};
+ if ($command eq 'verb') {
+ if ($line =~ /^$/) {
+ $current->{'type'} = '';
+ _line_error ($self, sprintf($self->
+ __("address@hidden without associated character"),
$command), $line_nr);
+ } else {
+ $line =~ s/^(.)//;
+ $current->{'type'} = $1;
+ }
+ }
+ $current->{'args'} = [ { 'parent' => $current,
+ 'contents' => [] } ];
+ $current->{'remaining_args'} = $brace_commands{$command} -1
+ if ($brace_commands{$command});
+ if ($self->{'definfoenclose'}->{$command}) {
+ $current->{'remaining_args'} = 0;
+ }
+ $current = $current->{'args'}->[-1];
+ # FIXME don't use type to distinguish context_brace_commands.
+ if ($context_brace_commands{$command}) {
+ push @{$self->{'context_stack'}},
$current->{'parent'}->{'cmdname'};
+ } else {
+ $current->{'type'} = 'brace_command_arg';
+ }
+ print STDERR "OPENED address@hidden>{'parent'}->{'cmdname'},
remaining: $current->{'parent'}->{'remaining_args'}, "
+ .($current->{'type'} ? "type: $current->{'type'}" : '')."\n"
+ if ($self->{'debug'});
+ } elsif ($current->{'parent'}
and (($current->{'parent'}->{'cmdname'}
and $current->{'parent'}->{'cmdname'} eq 'multitable')
or ($current->{'parent'}->{'type'}
Index: t/03coverage_braces.t
===================================================================
RCS file: /sources/texinfo/texinfo/tp/t/03coverage_braces.t,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- t/03coverage_braces.t 25 Sep 2010 10:01:34 -0000 1.4
+++ t/03coverage_braces.t 4 Oct 2010 22:10:54 -0000 1.5
@@ -9,7 +9,8 @@
['too_much_args', '@abbr{AZE, A truc Z b, E eep}'],
['footnote', 'address@hidden footnote.
address@hidden footnote r}. } after footnote.']
address@hidden footnote r}. } after footnote.'],
+['no_brace', '@TeX and @code code']
);
our ($arg_test_case, $arg_generate, $arg_debug);
Index: t/results/coverage_braces/no_brace.pl
===================================================================
RCS file: t/results/coverage_braces/no_brace.pl
diff -N t/results/coverage_braces/no_brace.pl
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ t/results/coverage_braces/no_brace.pl 4 Oct 2010 22:10:54 -0000
1.1
@@ -0,0 +1,60 @@
+use vars qw(%result_texts %result_trees %result_errors);
+
+$result_trees{'no_brace'} = {
+ 'contents' => [
+ {
+ 'contents' => [
+ {
+ 'cmdname' => 'TeX',
+ 'contents' => [],
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => ' and '
+ },
+ {
+ 'cmdname' => 'code',
+ 'contents' => [],
+ 'parent' => {}
+ },
+ {
+ 'parent' => {},
+ 'text' => ' code'
+ }
+ ],
+ 'parent' => {},
+ 'type' => 'paragraph'
+ }
+ ]
+};
+$result_trees{'no_brace'}{'contents'}[0]{'contents'}[0]{'parent'} =
$result_trees{'no_brace'}{'contents'}[0];
+$result_trees{'no_brace'}{'contents'}[0]{'contents'}[1]{'parent'} =
$result_trees{'no_brace'}{'contents'}[0];
+$result_trees{'no_brace'}{'contents'}[0]{'contents'}[2]{'parent'} =
$result_trees{'no_brace'}{'contents'}[0];
+$result_trees{'no_brace'}{'contents'}[0]{'contents'}[3]{'parent'} =
$result_trees{'no_brace'}{'contents'}[0];
+$result_trees{'no_brace'}{'contents'}[0]{'parent'} = $result_trees{'no_brace'};
+
+$result_texts{'no_brace'} = '@TeX and @code code';
+
+$result_errors{'no_brace'} = [
+ {
+ 'error_line' => ':1: @TeX expected braces
+',
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => '',
+ 'text' => '@TeX expected braces',
+ 'type' => 'error'
+ },
+ {
+ 'error_line' => ':1: @code expected braces
+',
+ 'file_name' => '',
+ 'line_nr' => 1,
+ 'macro' => '',
+ 'text' => '@code expected braces',
+ 'type' => 'error'
+ }
+];
+
+
- texinfo/tp Texinfo/Parser.pm t/03coverage_brace...,
Patrice Dumas <=