LangScan

DESCRIPTION:

program analyzer for source code search engine

FEATURES/PROBLEMS:

  • Support Languages

  • C

  • C++

  • C#

  • Java

  • JavaScript

  • Ruby

  • Python

  • PHP

  • Perl

  • Objective Caml

  • Brainfuck

  • CSS

  • Shell Script

  • Emacs Lisp

  • Scheme

  • Plain Text

  • Io

  • Lua

  • Eiffel

SYNOPSIS:

Example1

% cat -n hello.c
     1  #include <stdio.h>
     2
     3  int main(int argc, char **argv)
     4  {
     5    printf("Hello World.\n");
     6    return 0;
     7  }
% ruby -rlangscan/c -e 'LangScan::C.scan(ARGF.readlines.join) {|f| p f}' < hello.c
#<LangScan::Fragment space " " 1 (8)>
#<LangScan::Fragment ident "stdio" 1 (10)>
#<LangScan::Fragment punct "." 1 (15)>
#<LangScan::Fragment space "\n" 2 (19)>
#<LangScan::Fragment space " " 3 (23)>
#<LangScan::Fragment preproc_beg "#" 1 (0)>
#<LangScan::Fragment ident "include" 1 (1)>
...

Example2

% cat -n display_fundef.rb
   1  require 'langscan'
   2
   3  # display all function definitions.
   4  ARGV.each {|arg|
   5    next unless scanner = LangScan.choose(arg)
   6    scanner.scan(File.open(arg).readlines.join) {|f|
   7      if f.type == :fundef
   8        puts f.text
   9      end
  10    }
  11  }
% ruby display_fundef.rb hello.c
main

REQUIREMENTS:

  • Ruby 1.8.2+

  • Perl + PPI module (for source codes written in Perl)

  • OCaml (for source codes written in OCaml)

INSTALL:

  • sudo gem install langscan

LICENSE:

Copyright © 2004-2005 Satoru Takabayashi <[email protected]>

All rights reserved.
This is free software with ABSOLUTELY NO WARRANTY.

You can redistribute it and/or modify it under the terms of the GNU General Public License version 2.

AUTHORS:

see ‘AUTHORS.txt’