Skip to content

Code2Xml is a set of parsers for inter-converting between source code and xml supporting multiple programming languages. The NuGet package is also available from https://nuget.org/packages/Code2Xml .

License

Notifications You must be signed in to change notification settings

youfbi008/Code2Xml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code2Xml Build Status

Roadmap

  • 3.0.0 (April, 2014)
    • Add CstGeneraotr and AstGenerator classes
    • Add CstNode, CstToken, AstNode and AstToken classes instead of XElement class
    • Support inter-conversion between CstNode/AstNode and XElement classes
    • Remove Code2Xml, Xml2Code and Processor classes

How to Use

Sample Code using Processor

[Test] public void ParseJavaText() {
	var originalCode = @"class Klass {}";
	var xml = Processors.JavaUsingAntlr3.GenerateXml(originalCode);
	var code = Processors.JavaUsingAntlr3.GenerateCode(xml);
	Assert.That(code, Is.EqualTo(originalCode));
}

[Test] public void ParseCSharpFile() {
	var path = Fixture.GetInputCodePath("CSharp", "Student.cs"); // Get a path of a test file
	// To read file, please pass a FileInfo instance
	var xml = Processors.CSharpUsingAntlr3.GenerateXml(new FileInfo(path));
	var code = Processors.CSharpUsingAntlr3.GenerateCode(xml);
	Assert.That(code, Is.EqualTo(File.ReadAllText(path)));
}

[Test] public void ParseLuaFileUsingFilePath() {
	var path = Fixture.GetInputCodePath("Lua", "Block1.lua"); // Get a path of a test file
  // Load a suitable processor by retrieving an extension (e.g. .lua)
	var processor = Processors.GetProcessorByPath(path);
  // To read file, please pass a FileInfo instance
	var xml = processor.GenerateXml(new FileInfo(path));
	var code = processor.GenerateCode(xml);
	Assert.That(code, Is.EqualTo(File.ReadAllText(path)));
}

Note that Processor class is introduced in Code2Xml 2.x instead of CodeToXml and XmlToCode classes.

Requirements

Project Structure

  • Code2Xml.Languages.ANTLRv3.dll
    Provides Processor classes for C, C#, Java, JavaScript, Lua and PHP.

  • Code2Xml.Languages.ExternalProcessors.dll
    Provides Processor classes for Python and Ruby.

  • Code2Xml.Languages.Obsolete.dll
    Provides CodeToXml and XmlToCode classes, which are obsolete, for C, C#, Java, JavaScript, Lua, Python and Ruby.

  • Code2Xml.Languages.ANTLRv4.dll (under experiment)
    Provides Processor classes for C, Clojure, Erlang, Java, Lua, ObjectiveC, R and Verilog2001.

Other Information

How to Develop / Contribute

How to Build

  1. git submodule update --init at the root directory
  2. git submodule update --init at the ParserTests directory
  3. Open Code2Xml.sln
  4. Right click the Code2Xml solution in Solution Explorer.
  5. Select Enable NuGet Package Restore.
  6. Build the solution.

About

Code2Xml is a set of parsers for inter-converting between source code and xml supporting multiple programming languages. The NuGet package is also available from https://nuget.org/packages/Code2Xml .

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 79.2%
  • Ruby 17.7%
  • ANTLR 1.6%
  • GAP 1.5%