diff options
author | Arne Georg Gleditsch <argggh@lxr.linpro.no> | 2007-07-05 00:51:08 +0200 |
---|---|---|
committer | Arne Georg Gleditsch <argggh@lxr.linpro.no> | 2007-07-05 00:51:08 +0200 |
commit | e9fa4c98bb5f084739d3418ade3f0c51e34a0aa1 (patch) | |
tree | fec1d635625e031cde7cba1b0a1d95ee92ac760b /lib/LXRng/Lang.pm |
Rebase tree.
Diffstat (limited to 'lib/LXRng/Lang.pm')
-rw-r--r-- | lib/LXRng/Lang.pm | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/LXRng/Lang.pm b/lib/LXRng/Lang.pm new file mode 100644 index 0000000..7e6c278 --- /dev/null +++ b/lib/LXRng/Lang.pm @@ -0,0 +1,56 @@ +package LXRng::Lang; + +use strict; +use vars qw(@languages %deftypes %defweight); + + +%deftypes = + ( + 'c' => 'class', + 'd' => 'macro (un)definition', + 'e' => 'enumerator', + 'f' => 'function', + 'g' => 'enumeration name', + 'm' => 'class, struct, or union member', + 'n' => 'namespace', + 'p' => 'function prototype or declaration', + 's' => 'structure', + 't' => 'typedef', + 'u' => 'union', + 'v' => 'variable', + 'l' => 'local variable', + 'x' => 'extern or forward variable declaration', + 'i' => 'interface' + ); + +%defweight = do { my $i = 0; + map { $_ => $i++ } + qw(c f i n s t u p x v d e g m l) }; + + +sub import { + my ($self, @langs) = @_; + + push(@langs, 'Undefined'); + foreach my $l (@langs) { + eval "require LXRng::Lang::$l"; + die $@ if $@; + push(@languages, "LXRng::Lang::$l"); + } +} + +sub new { + my ($self, $file) = @_; + + my $pathname = $file->name(); + + foreach my $l (@languages) { + if ($pathname =~ $l->pathexp) { + return $l; + } + } + + die "No language found for $pathname"; +} + +1; |