aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LXRng/Lang.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/LXRng/Lang.pm')
-rw-r--r--lib/LXRng/Lang.pm56
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;