| 6483 |
|
|
| 6484 |
## Step 8 # MUST |
## Step 8 # MUST |
| 6485 |
my $i = 0; |
my $i = 0; |
| 6486 |
my $line = 1; |
$p->{line_prev} = $p->{line} = 1; |
| 6487 |
my $column = 0; |
$p->{column_prev} = $p->{column} = 0; |
| 6488 |
$p->{set_next_char} = sub { |
$p->{set_next_char} = sub { |
| 6489 |
my $self = shift; |
my $self = shift; |
| 6490 |
|
|
| 6493 |
|
|
| 6494 |
$self->{next_char} = -1 and return if $i >= length $$s; |
$self->{next_char} = -1 and return if $i >= length $$s; |
| 6495 |
$self->{next_char} = ord substr $$s, $i++, 1; |
$self->{next_char} = ord substr $$s, $i++, 1; |
| 6496 |
$column++; |
|
| 6497 |
|
($p->{line_prev}, $p->{column_prev}) = ($p->{line}, $p->{column}); |
| 6498 |
|
$p->{column}++; |
| 6499 |
|
|
| 6500 |
if ($self->{next_char} == 0x000A) { # LF |
if ($self->{next_char} == 0x000A) { # LF |
| 6501 |
$line++; |
$p->{line}++; |
| 6502 |
$column = 0; |
$p->{column} = 0; |
| 6503 |
!!!cp ('i1'); |
!!!cp ('i1'); |
| 6504 |
} elsif ($self->{next_char} == 0x000D) { # CR |
} elsif ($self->{next_char} == 0x000D) { # CR |
| 6505 |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
$i++ if substr ($$s, $i, 1) eq "\x0A"; |
| 6506 |
$self->{next_char} = 0x000A; # LF # MUST |
$self->{next_char} = 0x000A; # LF # MUST |
| 6507 |
$line++; |
$p->{line}++; |
| 6508 |
$column = 0; |
$p->{column} = 0; |
| 6509 |
!!!cp ('i2'); |
!!!cp ('i2'); |
| 6510 |
} elsif ($self->{next_char} > 0x10FFFF) { |
} elsif ($self->{next_char} > 0x10FFFF) { |
| 6511 |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
$self->{next_char} = 0xFFFD; # REPLACEMENT CHARACTER # MUST |
| 6521 |
|
|
| 6522 |
my $ponerror = $onerror || sub { |
my $ponerror = $onerror || sub { |
| 6523 |
my (%opt) = @_; |
my (%opt) = @_; |
| 6524 |
warn "Parse error ($opt{type}) at line $opt{line} column $opt{column}\n"; |
my $line = $opt{line}; |
| 6525 |
|
my $column = $opt{column}; |
| 6526 |
|
if (defined $opt{token} and defined $opt{token}->{line}) { |
| 6527 |
|
$line = $opt{token}->{line}; |
| 6528 |
|
$column = $opt{token}->{column}; |
| 6529 |
|
} |
| 6530 |
|
warn "Parse error ($opt{type}) at line $line column $column\n"; |
| 6531 |
}; |
}; |
| 6532 |
$p->{parse_error} = sub { |
$p->{parse_error} = sub { |
| 6533 |
$ponerror->(@_, line => $line, column => $column); |
$ponerror->(line => $p->{line}, column => $p->{column}, @_); |
| 6534 |
}; |
}; |
| 6535 |
|
|
| 6536 |
$p->_initialize_tokenizer; |
$p->_initialize_tokenizer; |
| 6610 |
## ISSUE: mutation events? |
## ISSUE: mutation events? |
| 6611 |
|
|
| 6612 |
$p->_terminate_tree_constructor; |
$p->_terminate_tree_constructor; |
| 6613 |
|
|
| 6614 |
|
delete $p->{parse_error}; # delete loop |
| 6615 |
} else { |
} else { |
| 6616 |
die "$0: |set_inner_html| is not defined for node of type $nt"; |
die "$0: |set_inner_html| is not defined for node of type $nt"; |
| 6617 |
} |
} |