- 3.0.0 (April, 2014)
- Add
CstGeneraotr
andAstGenerator
classes - Add
CstNode
,CstToken
,AstNode
andAstToken
classes instead ofXElement
class - Support inter-conversion between
CstNode/AstNode
andXElement
classes - Remove
Code2Xml
,Xml2Code
andProcessor
classes
- Add
- https://github.com/exKAZUu/Code2Xml/blob/master/Code2Xml.Languages/Tests/Samples/ProcessorSample.cs
- Parse C#, Java and Lua code.
- https://github.com/exKAZUu/Code2Xml/blob/master/Code2Xml.Languages/Tests/Samples/ManipulationSample.cs
- ProcessIdentifiers: Extract identifiers including a method name
- ProcessComments: Extract comments
- InsertStatements: Insert a statement into each method
[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.
- NuGet You can install NuGet Package Manager with Extension Manager.
- Code Contracts http://research.microsoft.com/en-us/projects/contracts/
- Python 2.x for parsing Python 2.x
- Python 3.x for parsing Python 3.x
- Ruby 2.x for parsing Ruby 1.8.x, 1.9.x and 2.0.x
-
Code2Xml.Languages.ANTLRv3.dll
ProvidesProcessor
classes for C, C#, Java, JavaScript, Lua and PHP. -
Code2Xml.Languages.ExternalProcessors.dll
ProvidesProcessor
classes for Python and Ruby. -
Code2Xml.Languages.Obsolete.dll
ProvidesCodeToXml
andXmlToCode
classes, which are obsolete, for C, C#, Java, JavaScript, Lua, Python and Ruby. -
Code2Xml.Languages.ANTLRv4.dll (under experiment)
ProvidesProcessor
classes for C, Clojure, Erlang, Java, Lua, ObjectiveC, R and Verilog2001.
git submodule update --init
at the root directorygit submodule update --init
at theParserTests
directory- Open
Code2Xml.sln
- Right click the
Code2Xml
solution in Solution Explorer. - Select
Enable NuGet Package Restore
. - Build the solution.