W3C home > Mailing lists > Public > w3c-wai-er-ig@w3.org > April 2000

Re: CSS parser perl module

From: Bert Bos <Bert.Bos@sophia.inria.fr>
Date: Fri, 14 Apr 2000 13:27:57 +0200 (MEST)
To: "Leonard R. Kasday" <kasday@acm.org>
Cc: w3c-wai-er-ig@w3.org
Message-ID: <14582.65025.34636.740423@lanalana.inria.fr>
Hello Len,

> Actually, I hadn't tried it <blush />.  I just spotted it and sent the info 
> to you. Would you send me the code you were testing it with?

Here is the program:

#

use CSS::Parser;

sub css_com {
  my $self = shift;
  my $comment = shift;
  print "comment: $comment\n";
}

sub sel {
  my $self = shift;
  my $selector = shift;
  print "selector: $selector\n";
}

sub blk_s {
  my $self = shift;
  print "block start\n";
}

sub prop {
  my $self = shift;
  my $property = shift;
  print "property: $property\n";
}

sub val {
  my $self = shift;
  my $value = shift;
  print "value: $value\n";
}

sub blk_e {
  my $self = shift;
  print "block end\n";
}

sub atr {
  my $self = shift;
  my $rule = shift;
  print "at-rule: $rule\n";
}

sub ats {
  my $self = shift;
  my $symbol = shift;
  print "at-symbol: $symbol\n";
}

sub error {
  my $self = shift;
  my $rest = shift;
  my $err = shift;
  print "Error: $err\n";
}

my $css = CSS::Parser->new(
			   handlers => {
					css_comment      => \&css_com,
					selector_string  => \&sel,
					block_start      => \&blk_s,
					property         => \&prop,
					value            => \&val,
					block_end        => \&blk_e,
					at_rule          => \&atr,
					at_symbol        => \&ats,
					error            => \&error
				       }
			  );

$/ = undef;
my $buf = <>;
$css->parse(\$buf);






-- 
  Bert Bos                                ( W 3 C ) http://www.w3.org/
  http://www.w3.org/people/bos/                              W3C/INRIA
  bert@w3.org                             2004 Rt des Lucioles / BP 93
  +33 (0)4 92 38 76 92            06902 Sophia Antipolis Cedex, France
Received on Friday, 14 April 2000 07:28:49 GMT

This archive was generated by hypermail 2.2.0 + w3c-0.30 : Thursday, 9 June 2005 12:10:34 GMT