Update of /cvsroot/lxr/lxr/lib/LXR/Lang
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10214/lib/LXR/Lang
Modified Files:
Generic.pm
Log Message:
* Removed invalid dependency from LXR::Lang -> LXR::Lang::Generic introduced in fix for bug 2752690 (C / C++ pre-processor keywords aren't marked as reserved)
* Clarified LXR::Lang interface by giving a dummy implementation for all required subroutines
Index: Generic.pm
===================================================================
RCS file: /cvsroot/lxr/lxr/lib/LXR/Lang/Generic.pm,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- Generic.pm 11 Apr 2009 11:23:43 -0000 1.20
+++ Generic.pm 12 Apr 2009 16:10:36 -0000 1.21
@@ -134,7 +134,6 @@
# This method returns the regexps used by SimpleParse to break the
# code into different blocks such as code, string, include, comment etc.
# Since this depends on the language, it's configured via generic.conf
-
sub parsespec {
my ($self) = @_;
my @spec = $self->langinfo('spec');
@@ -153,6 +152,8 @@
my ($self, $code) = @_;
my ($start, $id);
+ $self->processreserved($code);
+
# Replace identifier by link unless it's a reserved word
$$code =~
s{
@@ -161,12 +162,35 @@
{
$1.
(
- $self->isreserved($2) ? "<span class='reserved'>$2</span>" :
- ($index->issymbol($2, $$self{'release'}) ? join($2, @{$$self{'itag'}}) : $2)
+ $index->issymbol($2, $$self{'release'}) ? join($2, @{$$self{'itag'}}) : $2
);
}gex;
}
+sub isreserved {
+ my ($self, $frag) = @_;
+
+ foreach my $word (@{$self->langinfo('reserved')}) {
+ return 1 if $frag eq $word;
+ }
+ return 0;
+}
+
+sub processreserved {
+ my ($self, $frag) = @_;
+
+ # Replace reserved words
+ $$frag =~
+ s{
+ (^|[^\w\#])([\w~\#][\w]*)\b
+ }
+ {
+ $1.
+ ( $self->isreserved($2) ? "<span class='reserved'>$2</span>" : $2 ).
+ $3;
+ }gex;
+}
+
#
# Find references to symbols in the file
#
@@ -274,6 +298,11 @@
}
}
+sub language {
+ my ($self) = @_;
+ return $self->{'language'};
+}
+
sub langinfo {
my ($self, $item) = @_;
|