1 |
package Whatpm::CSS::Tokenizer; |
package Whatpm::CSS::Tokenizer; |
2 |
use strict; |
use strict; |
3 |
|
|
4 |
|
require Exporter; |
5 |
|
push our @ISA, 'Exporter'; |
6 |
|
|
7 |
sub BEFORE_TOKEN_STATE () { 0 } |
sub BEFORE_TOKEN_STATE () { 0 } |
8 |
sub BEFORE_NMSTART_STATE () { 1 } |
sub BEFORE_NMSTART_STATE () { 1 } |
9 |
sub NAME_STATE () { 2 } |
sub NAME_STATE () { 2 } |
79 |
COMMENT_INVALID EOF MINUS STAR VBAR DOT COLON MATCH EXCLAMATION |
COMMENT_INVALID EOF MINUS STAR VBAR DOT COLON MATCH EXCLAMATION |
80 |
); |
); |
81 |
|
|
82 |
|
our @EXPORT_OK = qw( |
83 |
|
IDENT_TOKEN ATKEYWORD_TOKEN HASH_TOKEN FUNCTION_TOKEN URI_TOKEN |
84 |
|
URI_INVALID_TOKEN URI_PREFIX_TOKEN URI_PREFIX_INVALID_TOKEN |
85 |
|
STRING_TOKEN INVALID_TOKEN NUMBER_TOKEN DIMENSION_TOKEN PERCENTAGE_TOKEN |
86 |
|
UNICODE_RANGE_TOKEN DELIM_TOKEN PLUS_TOKEN GREATER_TOKEN COMMA_TOKEN |
87 |
|
TILDE_TOKEN DASHMATCH_TOKEN PREFIXMATCH_TOKEN SUFFIXMATCH_TOKEN |
88 |
|
SUBSTRINGMATCH_TOKEN INCLUDES_TOKEN SEMICOLON_TOKEN LBRACE_TOKEN |
89 |
|
RBRACE_TOKEN LPAREN_TOKEN RPAREN_TOKEN LBRACKET_TOKEN RBRACKET_TOKEN |
90 |
|
S_TOKEN CDO_TOKEN CDC_TOKEN COMMENT_TOKEN COMMENT_INVALID_TOKEN EOF_TOKEN |
91 |
|
MINUS_TOKEN STAR_TOKEN VBAR_TOKEN DOT_TOKEN COLON_TOKEN MATCH_TOKEN |
92 |
|
EXCLAMATION_TOKEN |
93 |
|
); |
94 |
|
|
95 |
|
our %EXPORT_TAGS = ('token' => [@EXPORT_OK]); |
96 |
|
|
97 |
sub new ($) { |
sub new ($) { |
98 |
my $self = bless {token => [], get_char => sub { -1 }, |
my $self = bless {token => [], get_char => sub { -1 }, |
99 |
onerror => sub { }}, shift; |
onerror => sub { }}, shift; |