mirror of
https://github.com/twiglet/cs2j.git
synced 2025-01-18 13:15:17 +01:00
Merge updates from productized branch
- Accept (and discard) generic types in the parser - Add README.txt - Don't add static modifier to class - Add antform launcher to build.xml
This commit is contained in:
parent
416040160e
commit
1442852119
@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 9.00
|
|||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Translator", "Translator\Translator.csproj", "{D33074E4-1525-4F22-A1DB-A7F30989D8FE}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Translator", "Translator\Translator.csproj", "{D33074E4-1525-4F22-A1DB-A7F30989D8FE}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8ECA4801-3F48-4FD1-91B4-4DFB567D913B}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{8ECA4801-3F48-4FD1-91B4-4DFB567D913B}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
README.txt = README.txt
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
28
CSharpTranslator/README.txt
Normal file
28
CSharpTranslator/README.txt
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
Welcome to CS2J, a C# to Java translator
|
||||||
|
|
||||||
|
In this directory you will find:
|
||||||
|
|
||||||
|
Translator: A C# project that can be built in Visual Studio 2005. It requires a version of Antlr that can generate C# to be on
|
||||||
|
your path. It builds to a command line application. Run it without arguments to see how to use it to translate C# projects to Java.
|
||||||
|
Although the project knows to use antlr to build the grammar files VS2005 has trouble with getting the dependencies straight. For
|
||||||
|
a trouble free development I suggest you run MSBuild directly in the project directory, e.g.:
|
||||||
|
|
||||||
|
kevin.glynn@D11624C1 ~/winhome/My Documents/Visual Studio 2005/Projects/Translator/Translator
|
||||||
|
$ /cygdrive/c/WINDOWS/Microsoft.NET/Framework/v2.0.50727/MSBuild.exe
|
||||||
|
|
||||||
|
works for me under cygwin.
|
||||||
|
|
||||||
|
In order that the -show<etc> options work you will need to add antlr.astframe.dll and antlr.runtime.dll (from the antlr distribution)
|
||||||
|
to your project references.
|
||||||
|
|
||||||
|
|
||||||
|
CS2JLibrary: These are the XML translation files for the .NET library. Copy them into your filesystem, this location will be passed
|
||||||
|
as your translator's -netdir argument.
|
||||||
|
|
||||||
|
CS2JLibrary: This is a Java project containing supporting code that will be required by the translated code to build and
|
||||||
|
run. Load it into a project in your Java environment and make your translated project depend on it.
|
||||||
|
|
||||||
|
|
||||||
|
Disclaimer: By the way, the translator doesn't quite work yet ....
|
||||||
|
|
||||||
|
Kevin (kevin.glynn@scorm.com)
|
@ -114,8 +114,11 @@ namespace RusticiSoftware.Translator
|
|||||||
|
|
||||||
public void CopyPositionFrom(ASTNode other)
|
public void CopyPositionFrom(ASTNode other)
|
||||||
{
|
{
|
||||||
Line = other.Line;
|
if (other != null) // it might be if we are recovering from a parse error
|
||||||
Column = other.Column;
|
{
|
||||||
|
Line = other.Line;
|
||||||
|
Column = other.Column;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
|
@ -346,7 +346,8 @@ type!
|
|||||||
ASTNode starsBase = #[STARS, "STARS"];
|
ASTNode starsBase = #[STARS, "STARS"];
|
||||||
}
|
}
|
||||||
: (
|
: (
|
||||||
( p:predefinedTypeName { typeBase = #p; } | q:qualifiedIdentifier { typeBase = #q; } ) // typeName
|
( p:predefinedTypeName { typeBase = #p; } |
|
||||||
|
q:qualifiedIdentifier { typeBase = #q; } (LTHAN type (COMMA type)* GTHAN)? ) // typeName
|
||||||
(
|
(
|
||||||
s1:STAR // pointerType
|
s1:STAR // pointerType
|
||||||
{
|
{
|
||||||
@ -1097,7 +1098,7 @@ modifier
|
|||||||
//
|
//
|
||||||
|
|
||||||
classDeclaration! [AST attribs, AST modifiers]
|
classDeclaration! [AST attribs, AST modifiers]
|
||||||
: cl:CLASS id:identifier ba:classBase bo:classBody ( options { greedy = true; } : SEMI! )?
|
: cl:CLASS id:identifier (LTHAN type (COMMA type)* GTHAN)? ba:classBase bo:classBody ( options { greedy = true; } : SEMI! )?
|
||||||
{ ## = #( #cl, #attribs, #modifiers, #id, #ba, #bo ); }
|
{ ## = #( #cl, #attribs, #modifiers, #id, #ba, #bo ); }
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -1660,7 +1661,7 @@ delegateDeclaration! [AST attribs, AST modifiers]
|
|||||||
typ1:voidAsType { typ = #typ1; }
|
typ1:voidAsType { typ = #typ1; }
|
||||||
| typ2:type { typ = #typ2; }
|
| typ2:type { typ = #typ2; }
|
||||||
)
|
)
|
||||||
id:identifier OPEN_PAREN! ( fp:formalParameterList )? CLOSE_PAREN! SEMI!
|
id:identifier (LTHAN type (COMMA type)* GTHAN)? OPEN_PAREN! ( fp:formalParameterList )? CLOSE_PAREN! SEMI!
|
||||||
{ ## = #( #dlg, #attribs, #modifiers, #typ, #id, #fp ); }
|
{ ## = #( #dlg, #attribs, #modifiers, #typ, #id, #fp ); }
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ options {
|
|||||||
private XmlTextWriter enumXmlWriter;
|
private XmlTextWriter enumXmlWriter;
|
||||||
private ArrayList enumMembers = new ArrayList();
|
private ArrayList enumMembers = new ArrayList();
|
||||||
|
|
||||||
|
private bool inClassModifiers = false; // Filter out static, this isn't the right place but pending rewrite this is quickest.
|
||||||
|
|
||||||
/** walk list of hidden tokens in order, printing them out */
|
/** walk list of hidden tokens in order, printing them out */
|
||||||
public void dumpHidden(TextWriter w, antlr.IHiddenStreamToken t) {
|
public void dumpHidden(TextWriter w, antlr.IHiddenStreamToken t) {
|
||||||
for ( ; t!=null ; t=filter.getHiddenAfter(t) ) {
|
for ( ; t!=null ; t=filter.getHiddenAfter(t) ) {
|
||||||
@ -277,8 +279,8 @@ importDefinition [TextWriter w]
|
|||||||
;
|
;
|
||||||
|
|
||||||
typeDefinition [TextWriter w]
|
typeDefinition [TextWriter w]
|
||||||
: #(cl:CLASS
|
: #(cl:CLASS {inClassModifiers = true; }
|
||||||
modifiers[w]
|
modifiers[w] {inClassModifiers = false; }
|
||||||
id:IDENTIFIER { Print(w, "class "); Print(w, #id, " "); }
|
id:IDENTIFIER { Print(w, "class "); Print(w, #id, " "); }
|
||||||
extendsClause[w]
|
extendsClause[w]
|
||||||
implementsClause[w] { PrintNL(w); Print(w, "{"); PrintNL(w); indentLevel++; }
|
implementsClause[w] { PrintNL(w); Print(w, "{"); PrintNL(w); indentLevel++; }
|
||||||
@ -366,7 +368,7 @@ modifier [TextWriter w]
|
|||||||
: mpr:"private" { Print(w, #mpr); }
|
: mpr:"private" { Print(w, #mpr); }
|
||||||
| mpu:"public" { Print(w, #mpu); }
|
| mpu:"public" { Print(w, #mpu); }
|
||||||
| mpt:"protected" { Print(w, #mpt); }
|
| mpt:"protected" { Print(w, #mpt); }
|
||||||
| mst:"static" { Print(w, #mst); }
|
| mst:"static" { if (!inClassModifiers) {Print(w, #mst);} }
|
||||||
| mtr:"transient" { Print(w, #mtr); }
|
| mtr:"transient" { Print(w, #mtr); }
|
||||||
| mfi:FINAL { Print(w, #mfi); }
|
| mfi:FINAL { Print(w, #mfi); }
|
||||||
| mab:ABSTRACT { Print(w, #mab); }
|
| mab:ABSTRACT { Print(w, #mab); }
|
||||||
@ -749,7 +751,7 @@ constant [TextWriter w]
|
|||||||
| st:STRING_LITERAL { Print(w, #st); }
|
| st:STRING_LITERAL { Print(w, #st); }
|
||||||
| fl:NUM_FLOAT { Print(w, #fl); }
|
| fl:NUM_FLOAT { Print(w, #fl); }
|
||||||
| db:DOUBLE_LITERAL { Print(w, #db); }
|
| db:DOUBLE_LITERAL { Print(w, #db); }
|
||||||
| flr:FLOAT_LITERAL { Print(w, #flr); }
|
| flt:FLOAT_LITERAL { Print(w, #flt); }
|
||||||
| lo:LONG_LITERAL { Print(w, #lo); Print(w, "L"); }
|
| lo:LONG_LITERAL { Print(w, #lo); Print(w, "L"); }
|
||||||
| ul:ULONG_LITERAL { Print(w, #ul); Print(w, "L"); }
|
| ul:ULONG_LITERAL { Print(w, #ul); Print(w, "L"); }
|
||||||
| de:DECIMAL_LITERAL { Print(w, #de, "/* Unsupported Decimal Literal */"); }
|
| de:DECIMAL_LITERAL { Print(w, #de, "/* Unsupported Decimal Literal */"); }
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
<?xml-stylesheet type="text/xsl" href="file://C:\ant\etc\antex\antprettybuild\antprettybuild-3.1.1.xsl"?>
|
<?xml-stylesheet type="text/xsl" href="file://C:\ant\etc\antex\antprettybuild\antprettybuild-3.1.1.xsl"?>
|
||||||
<project name="cs2jTranslator" default="" basedir="." xmlns:dn="antlib:org.apache.ant.dotnet">
|
<project name="cs2jTranslator" default="launch" basedir="." xmlns:dn="antlib:org.apache.ant.dotnet">
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
This script builds the cs2j translator and translates C# code
|
This script builds the cs2j translator and translates C# code
|
||||||
</description>
|
</description>
|
||||||
|
|
||||||
|
<property file="${basedir}/launch.properties" />
|
||||||
<property file="${user.home}/${ant.project.name}.build.properties" />
|
<property file="${user.home}/${ant.project.name}.build.properties" />
|
||||||
<property file="${user.home}/build.properties" />
|
<property file="${user.home}/build.properties" />
|
||||||
<property file="build.properties" />
|
<property file="build.properties" />
|
||||||
@ -12,6 +13,44 @@
|
|||||||
<!-- load the ant-dotnet task, see http://ant.apache.org/antlibs/dotnet/index.html -->
|
<!-- load the ant-dotnet task, see http://ant.apache.org/antlibs/dotnet/index.html -->
|
||||||
<taskdef uri="antlib:org.apache.ant.dotnet" resource="org/apache/ant/dotnet/antlib.xml" classpath="${builder.ant.lib}/ant-dotnet-1.0.jar" />
|
<taskdef uri="antlib:org.apache.ant.dotnet" resource="org/apache/ant/dotnet/antlib.xml" classpath="${builder.ant.lib}/ant-dotnet-1.0.jar" />
|
||||||
|
|
||||||
|
<!-- Load AntForm tasks -->
|
||||||
|
<taskdef name="antform" classname="com.sardak.antform.AntForm" classpath="${builder.ant.lib}/antform.jar"/>
|
||||||
|
<taskdef name="antmenu" classname="com.sardak.antform.AntMenu" classpath="${builder.ant.lib}/antform.jar"/>
|
||||||
|
|
||||||
|
<target name="launch">
|
||||||
|
<antform title="C# to Java Translation" save="${basedir}/launch.properties">
|
||||||
|
<label>Enter a scratch directory to use for building</label>
|
||||||
|
<fileSelectionProperty label="Java output directory : " property="java.output.dir" directoryChooser="true" />
|
||||||
|
<fileSelectionProperty label="C# Application Root : " property="cs.app.dir" directoryChooser="true" />
|
||||||
|
<fileSelectionProperty label="C# Translation Root : " property="cs.tx.dir" directoryChooser="true" />
|
||||||
|
<fileSelectionProperty label="CS2J Translation Files : " property="cs2j.dir" directoryChooser="true" />
|
||||||
|
<separator />
|
||||||
|
<!-- <label>Enter the locations of the branches you want to translate from / to</label>
|
||||||
|
<textProperty label="ScormEngineNet branch : " property="csharp.project.full" />
|
||||||
|
<textProperty label="ScormEngineJava branch : " property="java.project.full" />
|
||||||
|
<separator />
|
||||||
|
<booleanProperty label="Commit Java code after translation " property="is.commit.javacode" />
|
||||||
|
<booleanProperty label="Refresh and Rebuild cs2j executable " property="is.rebuild.cs2j" />
|
||||||
|
-->
|
||||||
|
<controlbar>
|
||||||
|
<button label="Cancel" type="cancel" target="cancel" newproject="false"/>
|
||||||
|
<button label="Reset" type="reset" />
|
||||||
|
<button label="OK" type="ok"/>
|
||||||
|
</controlbar>
|
||||||
|
</antform>
|
||||||
|
<antcall target="ok" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="cancel">
|
||||||
|
<echo message="Translation cancelled by user" />
|
||||||
|
<property name="is.run.cancelled" value="true" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
<target name="ok" unless="is.run.cancelled">
|
||||||
|
<!--antcall target="dumpProperties" inheritall="false" / -->
|
||||||
|
<antcall target="translateCS2J" inheritall="false" />
|
||||||
|
</target>
|
||||||
|
|
||||||
|
|
||||||
<!-- We could have left this in the msbuild script fed to buildTranslator, but it is clearer in Ant :) -->
|
<!-- We could have left this in the msbuild script fed to buildTranslator, but it is clearer in Ant :) -->
|
||||||
<target name="antlrTranslator" depends="init">
|
<target name="antlrTranslator" depends="init">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user