Skip to content

victor-wiki/CodeParser

Repository files navigation

CodeParser

Parse code using antlr.

  • The lexer and parser classes in CodeParser are generated by Antlr grammar file.
  • The CodeParser.Test demonstrates how to parse source code file to extract class and interface with their properties and methods.
  • The CodeParser.Viewer is a visual tool to analyse the parser rules.

Example

Python

  • source code
#!/usr/bin/python3
 
class HelloWorld():   
    owner = ""
    target = ""
    def sayHello(self, word):
        print(word)

x = HelloWorld() 

x.sayHello("Hello")
  • parser test output
Class:HelloWorld
{
Field:owner
Field:target
Method:sayHello
}

Viewer

CodePaser Viewer

CodePaser Viewer

Use Case

The library SqlAnalyser.Core of DatabaseManager project uses the TSqlParser, MySqlParser, PlSqlParser and PostgreSqlParser to parse and translate view, function, procedure and table trigger between SqlServer, MySql, Oracle and Postgres.