Commits

Toby Inkster  committed 873b6e6

string

  • Participants
  • Parent commits cd2499d

Comments (0)

Files changed (2)

File examples/tokens.pl

 __DATA__
 @prefix foo: <http://example.com/foo> .
 
-<xyz> foo:bar 123 .
+<xyz>
+   foo:bar 123;
+   foo:baz "Yeah\"Baby\"Yeah".
 

File lib/Syntax/Highlight/RDF.pm

 sub _pull_token
 {
 	my $self = shift;
-	my ($spelling, $class) = @_;
+	my ($spelling, $class, %more) = @_;
 	substr(${$self->_remaining}, 0, length $spelling, "");
-	push @{$self->_tokens}, $class->new(spelling => $spelling);
+	push @{$self->_tokens}, $class->new(spelling => $spelling, %more);
 }
 
 sub _pull_bnode
 		if ${$self->_remaining} =~ m/^(([$nameStartChar2][$nameChar]*)?:([$nameStartChar2][$nameChar]*)?)/;
 }
 
+sub _pull_shortstring
+{
+	my $self = shift;	
+	my $quote_char = substr(${$self->_remaining}, 0, 1);
+	$self->_pull_token($1, ShortString, quote_char => $quote_char)
+		if ${$self->_remaining} =~ m/^($quote_char(?:\\\\|\\.|[^$quote_char])*?$quote_char)/;
+}
+
 sub _pull_longstring
 {
-	my $self = shift;
-	NotImplemented->throw;
-}
-
-sub _pull_shortstring
-{
-	my $self = shift;
-	NotImplemented->throw;
+	my $self = shift;	
+	my $quote_char = substr(${$self->_remaining}, 0, 1);
+	$self->_pull_token($1, LongString, quote_char => $quote_char)
+		if ${$self->_remaining} =~ m/^($quote_char{3}.*?$quote_char{3})/ms;
 }
 
 sub tokenize
 This is free software; you can redistribute it and/or modify it under
 the same terms as the Perl 5 programming language system itself.
 
-
 =head1 DISCLAIMER OF WARRANTIES
 
 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED