Language parsers

I need to parse C #, Ruby and Python source code to generate some reports. I need to get a list of method names inside a class, and I need other information, such as using a global variable or something like that. Just parsing using RE can be a solution, but I expect a better (systematic) solution using parsers, if that is easily possible.

What parsers are provided for these languages?

In C # I found http://csparser.codeplex.com/Wikipage , but for the rest I found a group of parsers using these languages, but not their parsers.

+3
source share
4 answers

, ANTLR.

ANTLR , ( Ruby "" ).

, , , . ANTLR , - . ( ) / ( ) , EBNF; , . "" ANTLR - Java, .

, ANTLR /,, 3- , , ( "" ), , , , , , "" , .

- , - "" , / (, , "" ), , .
, , ( ), , , (: , ... ).

:
, .
, , , , , , , -; , , ().

!
. ! . , : a) ; b) / , . , , -let - - .

+6

Python : Python parser, .

, Python ( , BEGIN END , Python ), , , Python , . (, Haskell, Python.)

Ruby .

Ruby , , , YACC YARV Ruby. (parse.y .) JRuby , , , . (, Eclipse RDT, Eclipse DLTK/Ruby, NetBeans Ruby jEdit Ruby, , JRuby-.) , JRuby .

, YACC . , YARV lex. C, YACC C. (, JRuby).

XRuby Ruby, YARV parse.y, ANTLRv3 ANTLRv3 , . ANTLR , , , Java #. Ruby backend, , .

RedParse - Ruby, Ruby, , Ruby. , , YARD Ruby, , .

ruby_parser - Ruby Ruby. parse.y racc, Ruby.

YARV , ripper, Ruby. , , , . , , , , .

Ruby. .

RDoc, Ruby, Ruby, Ruby , .

Cardinal - Ruby Parrot Virtual Machine. Ruby, , , . ( Parrot Grammar Engine, , , Parrot, , Perl6.)

tinyrb - Ruby, Ruby, , YARV. Ian Piumarta leg .

+6

Ruby Python , ? , ( , Python) - .

+2

DMS Software Reengineering Toolkit , # Python, . DMS , .

Another answer to this poster suggests that Ruby is really hard to make out. C ++ is also famously hard to parse. DMS is used to parse another 30 other languages, including full C ++ in a number of dialects, so Ruby seems extremely doable. Howeever, DMS does not have a ready-made parser for Ruby.

+1
source

Source: https://habr.com/ru/post/1741287/


All Articles