13 |
|
|
14 |
require Whatpm::WebIDL; |
require Whatpm::WebIDL; |
15 |
|
|
16 |
|
$self->result->layer_uncertain ('charset'); |
17 |
|
|
18 |
my $out = $self->output; |
my $out = $self->output; |
19 |
$out->start_section (id => 'parse-errors', title => 'Parse Errors'); |
$out->start_section (role => 'parse-errors'); |
20 |
$out->start_tag ('dl', id => 'parse-errors-list'); |
$out->start_error_list (role => 'parse-errors'); |
21 |
|
$self->result->layer_applicable ('syntax'); |
22 |
|
|
23 |
my $input = $self->input; |
my $input = $self->input; |
24 |
my $result = $self->result; |
my $result = $self->result; |
25 |
|
|
26 |
my $onerror = sub { |
$self->result->layer_uncertain ('encode') unless $input->{is_char_string}; |
|
my (%opt) = @_; |
|
|
my ($type, $cls, $msg) = main::get_text ($opt{type}, $opt{level}); |
|
|
$out->html (qq[<dt class="$cls">] . $result->get_error_label ($input, \%opt)); |
|
|
$type =~ tr/ /-/; |
|
|
$type =~ s/\|/%7C/g; |
|
|
$out->html (qq[<dd class="$cls">], $result->get_error_level_label (\%opt) . $msg); |
|
|
$out->text (' ['); |
|
|
$out->link ('Description', url => '../error-description#' . $type); |
|
|
$out->text (']'); |
|
|
|
|
|
main::add_error ('syntax', \%opt => $result); |
|
|
}; |
|
27 |
|
|
28 |
require Encode; |
require Encode; |
29 |
my $s = $input->{is_char_string} ? $input->{s} : Encode::decode ($input->{charset} || 'utf-8', $input->{s}); ## TODO: charset |
my $s = $input->{is_char_string} ? $input->{s} : Encode::decode ($input->{charset} || 'utf-8', $input->{s}); ## TODO: charset |
30 |
my $parser = Whatpm::WebIDL::Parser->new; |
my $parser = Whatpm::WebIDL::Parser->new; |
31 |
|
|
32 |
$self->{structure} = $parser->parse_char_string ($input->{s}, $onerror); |
$self->{structure} = $parser->parse_char_string ($input->{s}, sub { |
33 |
|
$result->add_error (@_, layer => 'syntax'); |
34 |
|
}); |
35 |
|
|
36 |
$out->html ('</dl></div>'); |
$out->end_error_list (role => 'parse-errors'); |
37 |
|
$out->end_section; |
38 |
} # generate_parse_error_section |
} # generate_parse_error_section |
39 |
|
|
40 |
sub generate_structure_dump_section ($) { |
sub generate_structure_dump_section ($) { |
41 |
my $self = shift; |
my $self = shift; |
42 |
|
|
43 |
my $out = $self->output; |
my $out = $self->output; |
44 |
|
|
45 |
$out->start_section (id => 'dump-webidl', title => 'WebIDL'); |
$out->start_section (role => 'reformatted'); |
46 |
|
|
47 |
$out->start_code_block; |
$out->start_code_block; |
48 |
$out->text ($self->{structure}->idl_text); |
$out->text ($self->{structure}->idl_text); |
49 |
$out->end_code_block; |
$out->end_code_block; |
50 |
|
|
51 |
$out->end_section |
$out->end_section |
52 |
} # generate_structure_dump_section |
} # generate_structure_dump_section |
53 |
|
|
54 |
|
sub generate_structure_error_section ($) { |
55 |
|
my $self = shift; |
56 |
|
|
57 |
|
my $out = $self->output; |
58 |
|
|
59 |
|
$out->start_section (role => 'structure-errors'); |
60 |
|
$out->start_error_list (role => 'structure-errors'); |
61 |
|
$self->result->layer_applicable ('structure'); |
62 |
|
|
63 |
|
$self->{structure}->check (sub { |
64 |
|
$self->result->add_error (@_, layer => 'structure'); |
65 |
|
}); |
66 |
|
|
67 |
|
$out->end_error_list (role => 'structure-errors'); |
68 |
|
$out->end_section; |
69 |
|
} # generate_structure_error_section |
70 |
|
|
71 |
1; |
1; |