aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 59a939014e8fe7888c518f8857b2208c7a6c357b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Couscous

Convert Java source code to other languages. C# and Python currently supported.

## Usage

1. Build the JAR:

    ```
    mvn package -Dmaven.test.skip=true
    ```

2. Create a file called `couscous.json`:

    ```
    {
      "backend": "csharp",
      "sourcepath": [
        "src/main/java"
      ],
      "files": [
        "src/main/java/com/example",
      ],
      "output": "dotnet/Example/generated.cs",
      "namespace": "Example"
    }
    ```

3. In the directory containing `couscous.json`:

    ```
    java -jar path/to/couscous.jar
    ```

## TODO

* Multiple constructors

* Remove all direct runtime support

* Type names for generics

* Type erasure

* Boxing and unboxing for `String`s

* Handle boxing/unboxing when overriding method in supertype with more/less
  specific return types/arguments. For instance, if an interface defines a
  method that returns `Object`, then a subtype may override that method
  returning `Integer`. We want `Integer` to be unboxed (in general),
  so that calling the method on the subtype returns an unboxed `Integer`,
  but if the caller is calling the method on the supertype, it will expect
  an `Object`, meaning it will need to be boxed. This probably means having
  two overloads -- one for the supertype, one for the subtype.

  This needs doing regardless of changes to boxing/unboxing primitives since
  we currently use raw strings rather than boxing them into Java strings.

## Python precedence

The table below gives precedence from lowest to highest in Python 3.5.
Some rows have the same precedence for serialisation to improve code
clarity.

Operator | Precedence (serialisation)
---------|-----------
`lambda` | 0
`if – else` | 10
`or` | 20
`and` | 20
`not x`  | 40
`in`, `not in`, `is`, `is not`, `<`, `<=`, `>`, `>=`, `!=`, `==` | 50
`|` | 60
`^` | 70
`&` | 80
`<<`, `>>` | 90
`+`, `-` | 100
`*`, `@`, `/`, `//`, `%` | 110
`+x`, `-x`, `~x` | 120
`**` | 130
`await x` | 140
`x[index]`, `x[index:index]`, `x(arguments...)`, `x.attribute` | 150
`(expressions...)`, `[expressions...]`, `{key: value...}`, `{expressions...}`` | 160