From: É. R. <eds...@gm...> - 2008-08-27 16:32:13
|
---------- Forwarded message ---------- From: Édson Rocha <eds...@gm...> Date: 2008/8/27 Subject: Re: [scala-br] java2scala: Pontapé inicial To: sca...@go..., jav...@li... A lista desenvolvedores do java2scala é * jav...@li...* Acredito que o primeiro passo seria o cadastro no sf.net, para que possamos providenciar permissões. 2008/8/27 Alexei Barbosa de Aguiar <al...@ve...> > Édson e Marcelo, já tenho trabalho para distribuir, já que estou vendo > outras partes do projeto. > O parser de Java já vem com testes unitários que fazem o seguinte. Ele > usar o parser para fazer o parsing de um código de teste que exercita muitas > das construções do Java. Depois, usa o visitor que repete o código para > devolver à forma original. Aí ele compara os dois códigos fonte. > No nosso caso, teremos o código fonte Java de teste e um código fonte > Scala traduzido manualmente para testar o visitor que vamos fazer. A tarefa > é traduzir o código Java de teste para Scala (anexo). > Seria interessante que mais de uma pessoa traduzisse para comparação. > Essas diretrizes desta página ( > http://lamp.epfl.ch/~emir/bqbase/2005/01/21/java2scala.html<http://lamp.epfl.ch/%7Eemir/bqbase/2005/01/21/java2scala.html>) > podem ser úteis. > > O Édson já recebeu a chave do SourceForge. Amanhã (se funcionar), > copiarei o projeto para o repositório de lá. Assim, posso dar mais > explicações sobre os códigos já que vocês vão ter acesso. Inclusive, vamos > passar a usar a lista de lá para não poluir esta. > > -- > Verde Tecnologia > > Alexei Barbosa de Aguiar > +55(85)8879.9005 > +55(85)3274.6644 > Skype: alexeiaguiar > > > package japa.parser.javacc; > > import japa.parser.JavaParser; > import japa.parser.ParseException; > import japa.parser.ast.CompilationUnit; > import java.io.File; > import java.io.IOException; > import java.io.Serializable; > import java.util.ArrayList; > import java.util.Comparator; > import java.util.List; > import java.util.Map; > > @Deprecated > public class Teste<T extends List<int[]>, X> extends Object implements > Serializable { > > Class clz1 = String.class; > > Class clz2 = (String.class); > > Class clz3 = int.class; > > Class clz4 = (int.class); > > int[] arr = new int[10]; > > ; > > class Ugly { > > int x = 0; > > public static void main(String[] args) { > } > } > > ; > > @Deprecated > int[][][][] arr2 = new int[10][2][1][0]; > > float fff = 0x1.fffeP+127f; > > char cc = 'a'; > > int[][] arr3 = { { 1, 2 }, { 3, 4 } }; > > static int[] arr4[] = {}; > > static { > arr4 = new int[][] { { 2 }, { 1 } }; > } > > public final enum Teste { > > asc, def > } > > public static enum Sexo { > > m, @deprecated > f; > > public static enum Sexo_ implements Serializable { > > } > > private Sexo() { > } > } > > public static enum Enum { > > m(1) { > > void mm() { > } > } > , f(2) { > > void mm() { > } > } > ; > > int x; > > private Enum(int x) { > this.x = x; > } > > abstract void mm(); > } > > public <T> Teste(int x) { > this.arr[0] = x; > super.<T, E>check2(val1, val2); > boolean b = true, y = false; > abstract class X { > > public X() { > } > > public void m() { > } > } > @Deprecated > final class Y extends X { > > public Y() { > super(); > Y.super.m(); > } > > public Y(int y) { > t.<Object>super(); > } > > public Y(int x) { > this(); > } > } > } > > private class QWE extends Teste<List<int[]>, String> { > > @Deprecated > final int z = 0; > > int i = (int) -1; > > public QWE(String... x) { > <String>super(x[0]); > } > > public QWE(int... x) { > super(x[0]); > i = x[0]; > assert true; > assert 1 == 1 : 2; > { > int iii = 3; > iii += 3; > } > label: { > int iii = 1; > } > ; > ; > switch(i) { > } > ll: switch(i) { > case 1: > System.out.println(1); > break ll; > default: > { > System.out.println("default"); > break; > } > case 2: > System.out.println(1); > i++; > ++i; > } > } > > private synchronized int doSomething()[] { > List<? extends Number> x = new ArrayList<Integer>(); > return new int[] { 1 }; > } > } > > public static void main(String[] args) throws ParseException, > IOException { > int x = 2; > CompilationUnit cu = parse(new > File("src/japa/parser/javacc/Parser.java")); > System.out.println(cu); > Teste teste = new Teste(2); > Teste.QWE qwe = teste.new QWE(1); > if (1 + 1 == 2) { > teste = null; > teste = new Teste(1); > } else { > x = 3; > teste = new Teste(1); > x = 2; > } > if (true) x = 1; else x = 3; > while (true) { > while (x == 3) continue; > break; > } > do { > x++; > } while (x < 100); > do x++; while (x < 100); > for (@Deprecated int i : arr4[0]) { > x--; > } > for (@Deprecated final int i = 0, j = 1; i < 10; x++) { > break; > } > int i, j; > for (i = 0, j = 1; i < 10 && j < 2; i++, j--) { > break; > } > } > > @AnnotationTest(value = "x") > public static CompilationUnit parse(@Deprecated File file) throws > ParseException, IOException { > String a = ((String) "qwe"); > String x = ((String) clz1); > int y = ((int) x); > synchronized (file) { > file = null; > file = new File(""); > } > try { > if (file == null) { > throw new NullPointerException("blah"); > } > } catch (final NullPointerException e) { > System.out.println("catch"); > } catch (RuntimeException e) { > System.out.println("catch"); > } finally { > System.out.println("finally"); > } > try { > if (file == null) { > throw new NullPointerException("blah"); > } > } finally { > System.out.println("finally"); > } > try { > if (file == null) { > throw new NullPointerException("blah"); > } > } catch (RuntimeException e) { > System.out.println("catch"); > } > return JavaParser.parse(file); > } > > private <Y> void x(Map<? extends X, ? super T> x) { > @Deprecated Comparator c = new Comparator() { > > public int compare(Object o1, Object o2) { > A<Integer> a = new <String>A<Integer>(new Integer(11), > "foo") { > }; > return 0; > } > > @Override > public boolean equals(Object obj) { > return super.equals(obj); > } > }; > } > > public @interface AnnotationTest { > > String value() default "asd"; > > @Deprecated > int[] valueI() default { 1, 2 }; > > AnnotationTest valueA1() default @AnnotationTest; > > AnnotationTest valueA2() default @AnnotationTest("qwe"); > > AnnotationTest valueA3() default @AnnotationTest(value = "qwe", > valueI = { 1 }); > } > > ; > } > > > -- Édson Rocha Patrício www.verde.com.br -- Édson Rocha Patrício www.verde.com.br |