| 1 |
package WebHACC::Language::WebIDL; |
| 2 |
use strict; |
| 3 |
require WebHACC::Language::Base; |
| 4 |
push our @ISA, 'WebHACC::Language::Base'; |
| 5 |
|
| 6 |
sub new ($) { |
| 7 |
my $self = bless {}, shift; |
| 8 |
return $self; |
| 9 |
} # new |
| 10 |
|
| 11 |
sub generate_syntax_error_section ($) { |
| 12 |
my $self = shift; |
| 13 |
|
| 14 |
require Whatpm::WebIDL; |
| 15 |
|
| 16 |
my $out = $self->output; |
| 17 |
$out->start_section (id => 'parse-errors', title => 'Parse Errors'); |
| 18 |
$out->start_tag ('dl', id => 'parse-errors-list'); |
| 19 |
|
| 20 |
my $input = $self->input; |
| 21 |
my $result = $self->result; |
| 22 |
|
| 23 |
require Encode; |
| 24 |
my $s = $input->{is_char_string} ? $input->{s} : Encode::decode ($input->{charset} || 'utf-8', $input->{s}); ## TODO: charset |
| 25 |
my $parser = Whatpm::WebIDL::Parser->new; |
| 26 |
|
| 27 |
$self->{structure} = $parser->parse_char_string ($input->{s}, sub { |
| 28 |
$result->add_error (@_, layer => 'syntax'); |
| 29 |
}); |
| 30 |
|
| 31 |
$out->html ('</dl></div>'); |
| 32 |
} # generate_parse_error_section |
| 33 |
|
| 34 |
sub generate_structure_dump_section ($) { |
| 35 |
my $self = shift; |
| 36 |
|
| 37 |
my $out = $self->output; |
| 38 |
|
| 39 |
$out->start_section (id => 'dump-webidl', title => 'WebIDL'); |
| 40 |
$out->start_code_block; |
| 41 |
$out->text ($self->{structure}->idl_text); |
| 42 |
$out->end_code_block; |
| 43 |
$out->end_section |
| 44 |
} # generate_structure_dump_section |
| 45 |
|
| 46 |
1; |