5 module mach.java.lang.Integer
6 syntax type integer "int"
7 syntax literal integer "%c"
9 syntax val min_integer "Integer.MIN_VALUE" prec 0
10 syntax val max_integer "Integer.MAX_VALUE" prec 0
12 syntax val (+) "%1 + %2" prec 4 4 3
13 syntax val (-) "%1 - %2" prec 4 4 3
14 syntax val (-_) "-%1" prec 2 1
15 syntax val ( * ) "%1 * %2" prec 3 3 2
16 syntax val (/) "%1 / %2" prec 3 3 2
17 syntax val (%) "%1 % %2" prec 3 3 2
18 syntax val (=) "%1 == %2" prec 7 7 6
19 syntax val (<=) "%1 <= %2" prec 6 6 5
20 syntax val (<) "%1 < %2" prec 6 6 5
21 syntax val (>=) "%1 >= %2" prec 6 6 5
22 syntax val (>) "%1 > %2" prec 6 6 5
24 syntax val to_int "(%1).intValue()"
29 module mach.java.lang.Long
30 syntax type long "long"
31 syntax literal long "%c"
33 syntax val min_long "Long.MIN_VALUE" prec 0
34 syntax val max_long "Long.MAX_VALUE" prec 0
36 syntax val (+) "%1 + %2" prec 4 4 3
37 syntax val (-) "%1 - %2" prec 4 4 3
38 syntax val (-_) "-%1" prec 2 1
39 syntax val ( * ) "%1 * %2" prec 3 3 2
40 syntax val (/) "%1 / %2" prec 3 3 2
41 syntax val (%) "%1 % %2" prec 3 3 2
42 syntax val (=) "%1 == %2" prec 7 7 6
43 syntax val (<=) "%1 <= %2" prec 6 6 5
44 syntax val (<) "%1 < %2" prec 6 6 5
45 syntax val (>=) "%1 >= %2" prec 6 6 5
46 syntax val (>) "%1 > %2" prec 6 6 5
48 syntax val of_integer "Long.valueOf(%1)" prec 15 15
49 syntax val int_value "Integer.valueOf((int)%1)" prec 15 15
55 module mach.java.lang.Short
56 syntax type short "short"
57 syntax literal short "%c"
59 syntax val min_short "Short.MIN_VALUE" prec 0
60 syntax val max_short "Short.MAX_VALUE" prec 0
62 syntax val (+) "%1 + %2" prec 4 4 3
63 syntax val (-) "%1 - %2" prec 4 4 3
64 syntax val (-_) "-%1" prec 2 1
65 syntax val ( * ) "%1 * %2" prec 3 3 2
66 syntax val (/) "%1 / %2" prec 3 3 2
67 syntax val (%) "%1 % %2" prec 3 3 2
68 syntax val (=) "%1 == %2" prec 7 7 6
69 syntax val (<=) "%1 <= %2" prec 6 6 5
70 syntax val (<) "%1 < %2" prec 6 6 5
71 syntax val (>=) "%1 >= %2" prec 6 6 5
72 syntax val (>) "%1 > %2" prec 6 6 5
78 syntax type string "String"
79 syntax literal string "%c"
82 module mach.java.lang.String
84 syntax val equals "%1.equals (%2)" prec 15 14 14
85 syntax val concat "%1.concat (%2)" prec 15 14 14
86 syntax val of_integer "String.valueOf(%1)" prec 15
87 syntax val of_long "String.valueOf(%1)" prec 15
88 syntax val format_1 "String.format(%1, %2)" prec 15 14
89 syntax val format_2 "String.format(%1, %2, %3)" prec 15 14 14
90 syntax val format_3 "String.format(%1, %2, %3, %4)" prec 15 14 14 14
91 syntax val format_4 "String.format(%1, %2, %3, %4, %5)" prec 15 14 14 14 14
96 module mach.java.lang.System
97 syntax val out "System.out" prec 0
98 syntax val err "System.err" prec 0
103 module mach.java.io.PrintStream
104 prelude export "import java.io.PrintStream;"
106 syntax type print_stream "PrintStream"
108 syntax val print "%1.print(%2)" prec 15 14
109 syntax val println "%1.println(%2)" prec 15 14
114 module mach.java.util.NoSuchElementException
115 prelude export "import java.util.NoSuchElementException;"
116 syntax exception E "NoSuchElementException"
121 module mach.java.lang.IndexOutOfBoundsException
122 syntax exception E "IndexOutOfBoundsException"
126 module mach.java.lang.IllegalArgumentException
127 syntax exception E "IllegalArgumentException"
131 module mach.java.lang.ArithmeticException
132 syntax exception E "ArithmeticException"
136 module mach.java.util.Set
137 prelude export "import java.util.Set;"
138 prelude export "import java.util.HashSet;"
140 syntax type set "Set<%1>"
142 syntax val empty "new HashSet<> ()" prec 15
143 syntax val size "%1.size ()" prec 15
144 syntax val contains "%1.contains (%2)" prec 15
145 syntax val equals "%1.equals (%2)" prec 15
146 syntax val add "%1.add (%2)" prec 15 14 14
151 module mach.java.util.Map
152 prelude export "import java.util.Map;"
153 prelude export "import java.util.HashMap;"
155 syntax type map "Map<%1,%2>"
157 syntax val empty "new HashMap<> ()" prec 15
158 syntax val size "%1.size ()" prec 15
159 syntax val containsKey "%1.containsKey (%2)" prec 15
160 syntax val put "%1.put (%2, %3)" prec 15 14 14
161 syntax val get "%1.get (%2)" prec 15 14 14
166 module mach.java.util.List
167 prelude export "import java.util.List;"
168 prelude export "import java.util.ArrayList;"
170 syntax type list "List<%1>"
172 syntax val empty "new ArrayList<> ()" prec 15
173 syntax val size "%1.size()" prec 15
174 syntax val add "%1.add(%2)" prec 15 14 14
175 syntax val get "%1.get(%2)" prec 15 14 14
176 syntax val insert "%1.add(%2, %3)" prec 15 14 14 14
177 syntax val set "%1.set(%2, %3)" prec 15 14 14 14
179 (* List.copyOf needs JDKs >= 10 *)
180 syntax val copy_of "List.copyOf(%1)" prec 15 14
185 module mach.java.util.UnmodifiableList
186 prelude export "import java.util.List;"
188 syntax type ulist "List<%1>"
190 syntax val size "%1.size ()" prec 15
191 syntax val get "%1.get (%2)" prec 15 14 14
196 module mach.java.util.Queue
197 prelude export "import java.util.Queue;"
198 prelude export "import java.util.ArrayDeque;"
200 syntax type queue "Queue<%1>"
202 syntax val empty "new ArrayDeque()" prec 15
203 syntax val size "%1.size()" prec 15 14
204 syntax val poll "%1.poll()" prec 15 14
205 syntax val peek "%1.peek()" prec 15 14
206 syntax val add "%1.add(%2)" prec 15 14 14
207 syntax val is_empty "%1.isEmpty()" prec 15 14
208 syntax val equals "%1.equals(%2)" prec 15 14 14
213 module mach.java.util.Optional
214 prelude export "import java.util.Optional;"
216 syntax type optional "Optional<%1>"
218 syntax val empty "Optional.ofNullable(null)" prec 15
219 syntax val build "Optional.of(%1)" prec 15
220 syntax val is_present "%1.isPresent()" prec 15 14
221 syntax val is_empty "%1.isEmpty()" prec 15 14
222 syntax val get "%1.get()" prec 15 14
223 syntax val get_safe "%1.get()" prec 15 14
228 module pqueue.PqueueNoDup
239 syntax val (!) "%1" prec 2 1
240 syntax val (:=) "%1 = %2" prec 15 14
245 syntax val incr "%1 = %1+1" prec 15 14
246 syntax val decr "%1 = %1+1" prec 15 14
247 syntax val (+=) "%1 = %1+%2" prec 15 14
248 syntax val (-=) "%1 = %1-%2" prec 15 14
249 syntax val ( *=) "%1 = %1+%2" prec 15 14
254 module mach.java.lang.Array
255 prelude export "import java.util.Arrays;\n"
257 syntax type array "%1 []"
258 syntax val length "%1.length"
259 syntax val ([]) "%1[%2]" prec 1 1 15
260 syntax val ([]<-) "%1[%2] = %3" prec 1 1 15 14
262 (* syntax val equals "Objects.deepEquals(%1, %2)" prec 1 1 15 14 *)
263 (* syntax val hash_code "Arrays.deepHashCode(%1)" prec 1 1 15 14 *)
264 syntax val equals "%1.equals(%2)" prec 1 1 15 14
265 syntax val hash_code "%1.hashCode()" prec 1 1 15
270 module mach.java.util.Random
271 prelude export "import java.util.Random;\n"
273 syntax type random "Random"
274 syntax val create "new Random()"
275 syntax val create_init "new Random(%1)"
276 syntax val set_seed "%1.setSeed(%2)" prec 1 1 15 14
277 syntax val next_boolean "%1.nextBoolean()" prec 1 1 15
278 syntax val next_int "%1.nextInt()" prec 1 1 15
279 syntax val next_bounded_int "%1.nextInt(%2)" prec 1 1 15 14
284 (* remove some modules from the standard library *)
288 syntax type bool "boolean"
300 module number.Divisibility
312 module int.ComputerDivision
316 module int.EuclideanDivision
340 module real.RealInfix
348 module mach.int.Unsigned
356 module seq.FreeMonoid
372 module pigeon.Pigeonhole