Docs: Drop inline callouts from painless book (#40805)

Drops the inline callouts from the painless reference book. These
callouts are incompatible with Asciidoctor and we'd very much like to
switch to Asciidoctor for building this book, partially because
Asciidoctor is actively developed and AsciiDoc is not, and partially
because it builds the book three times faster.
This commit is contained in:
Nik Everett 2019-04-04 08:41:30 -04:00
parent 2756a3936b
commit fce1bbc20e
9 changed files with 489 additions and 489 deletions

View File

@ -28,9 +28,9 @@ cast: '(' TYPE ')' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = (int)5L; int i = (int)5L; <1>
<2> Map m = new HashMap(); Map m = new HashMap(); <2>
<3> HashMap hm = (HashMap)m; HashMap hm = (HashMap)m; <3>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -75,10 +75,10 @@ following table:
+ +
[source,Painless] [source,Painless]
---- ----
<1> int a = 1; int a = 1; <1>
<2> long b = a; long b = a; <2>
<3> short c = (short)b; short c = (short)b; <3>
<4> double e = (double)a; double e = (double)a; <4>
---- ----
+ +
<1> declare `int a`; <1> declare `int a`;
@ -101,9 +101,9 @@ following table:
+ +
[source,Painless] [source,Painless]
---- ----
<1> int a = 1.0; // error int a = 1.0; // error <1>
<2> int b = 2; int b = 2; <2>
<3> byte c = b; // error byte c = b; // error <3>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -132,11 +132,11 @@ or the target type is a descendant of the original type.
+ +
[source,Painless] [source,Painless]
---- ----
<1> List x; List x; <1>
<2> ArrayList y = new ArrayList(); ArrayList y = new ArrayList(); <2>
<3> x = y; x = y; <3>
<4> y = (ArrayList)x; y = (ArrayList)x; <4>
<5> x = (List)y; x = (List)y; <5>
---- ----
+ +
<1> declare `List x`; <1> declare `List x`;
@ -161,9 +161,9 @@ or the target type is a descendant of the original type.
+ +
[source,Painless] [source,Painless]
---- ----
<1> List x = new ArrayList(); List x = new ArrayList(); <1>
<2> ArrayList y = x; // error ArrayList y = x; // error <2>
<3> Map m = (Map)x; // error Map m = (Map)x; // error <3>
---- ----
+ +
<1> declare `List x`; <1> declare `List x`;
@ -201,11 +201,11 @@ based on the current type value the `def` type value represents.
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d0 = 3; def d0 = 3; <1>
<2> d0 = new ArrayList(); d0 = new ArrayList(); <2>
<3> Object o = new HashMap(); Object o = new HashMap(); <3>
<4> def d1 = o; def d1 = o; <4>
<5> int i = d1.size(); int i = d1.size(); <5>
---- ----
+ +
<1> declare `def d0`; <1> declare `def d0`;
@ -236,12 +236,12 @@ based on the current type value the `def` type value represents.
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = 1.0; def d = 1.0; <1>
<2> int i = (int)d; int i = (int)d; <2>
<3> d = 1; d = 1; <3>
<4> float f = d; float f = d; <4>
<5> d = new ArrayList(); d = new ArrayList(); <5>
<6> List l = d; List l = d; <6>
---- ----
+ +
<1> declare `def d`; <1> declare `def d`;
@ -274,10 +274,10 @@ based on the current type value the `def` type value represents.
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = 1; def d = 1; <1>
<2> short s = d; // error short s = d; // error <2>
<3> d = new HashMap(); d = new HashMap(); <3>
<4> List l = d; // error List l = d; // error <4>
---- ----
<1> declare `def d`; <1> declare `def d`;
implicit cast `int 1` to `def` -> `def`; implicit cast `int 1` to `def` -> `def`;
@ -314,8 +314,8 @@ Use the cast operator to convert a <<string-type, `String` type>> value into a
+ +
[source,Painless] [source,Painless]
---- ----
<1> char c = (char)"C"; char c = (char)"C"; <1>
<2> c = (char)'c'; c = (char)'c'; <2>
---- ----
+ +
<1> declare `char c`; <1> declare `char c`;
@ -328,8 +328,8 @@ Use the cast operator to convert a <<string-type, `String` type>> value into a
+ +
[source,Painless] [source,Painless]
---- ----
<1> String s = "s"; String s = "s"; <1>
<2> char c = (char)s; char c = (char)s; <2>
---- ----
<1> declare `String s`; <1> declare `String s`;
store `String "s"` to `s`; store `String "s"` to `s`;
@ -350,8 +350,8 @@ Use the cast operator to convert a <<primitive-types, `char` type>> value into a
+ +
[source,Painless] [source,Painless]
---- ----
<1> char c = 65; char c = 65; <1>
<2> String s = (String)c; String s = (String)c; <2>
---- ----
<1> declare `char c`; <1> declare `char c`;
store `char 65` to `c`; store `char 65` to `c`;
@ -390,10 +390,10 @@ value and vice versa.
+ +
[source,Painless] [source,Painless]
---- ----
<1> List l = new ArrayList(); List l = new ArrayList(); <1>
<2> l.add(1); l.add(1); <2>
<3> Integer I = Integer.valueOf(0); Integer I = Integer.valueOf(0); <3>
<4> int i = l.get(i); int i = l.get(i); <4>
---- ----
+ +
<1> declare `List l`; <1> declare `List l`;
@ -421,10 +421,10 @@ value and vice versa.
+ +
[source,Painless] [source,Painless]
---- ----
<1> Integer x = 1; // error Integer x = 1; // error <1>
<2> Integer y = (Integer)1; // error Integer y = (Integer)1; // error <2>
<3> int a = Integer.valueOf(1); // error int a = Integer.valueOf(1); // error <3>
<4> int b = (int)Integer.valueOf(1); // error int b = (int)Integer.valueOf(1); // error <4>
---- ----
+ +
<1> declare `Integer x`; <1> declare `Integer x`;
@ -459,9 +459,9 @@ based on the type the `def` value represents.
+ +
[source,Painless] [source,Painless]
---- ----
<1> double d = 2 + 2.0; double d = 2 + 2.0; <1>
<2> def x = 1; def x = 1; <2>
<3> float f = x + 2.0F; float f = x + 2.0F; <3>
---- ----
<1> declare `double d`; <1> declare `double d`;
promote `int 2` and `double 2.0 @0`: result `double`; promote `int 2` and `double 2.0 @0`: result `double`;

View File

@ -30,12 +30,12 @@ HEX: '-'? '0' [xX] [0-9a-fA-F]+ [lL]?;
+ +
[source,Painless] [source,Painless]
---- ----
<1> 0 0 <1>
<2> 0D 0D <2>
<3> 1234L 1234L <3>
<4> -90f -90f <4>
<5> -022 -022 <5>
<6> 0xF2A 0xF2A <6>
---- ----
+ +
<1> `int 0` <1> `int 0`
@ -67,11 +67,11 @@ EXPONENT: ( [eE] [+\-]? [0-9]+ );
+ +
[source,Painless] [source,Painless]
---- ----
<1> 0.0 0.0 <1>
<2> 1E6 1E6 <2>
<3> 0.977777 0.977777 <3>
<4> -126.34 -126.34 <4>
<5> 89.9F 89.9F <5>
---- ----
+ +
<1> `double 0.0` <1> `double 0.0`

View File

@ -29,7 +29,7 @@ expression_list: expression (',' expression);
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[] x = new int[] {1, 2, 3}; int[] x = new int[] {1, 2, 3}; <1>
---- ----
+ +
<1> declare `int[] x`; <1> declare `int[] x`;
@ -44,12 +44,12 @@ expression_list: expression (',' expression);
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 1; int i = 1; <1>
<2> long l = 2L; long l = 2L; <2>
<3> float f = 3.0F; float f = 3.0F; <3>
<4> double d = 4.0; double d = 4.0; <4>
<5> String s = "5"; String s = "5"; <5>
<6> def array = new def[] {i, l, f*d, s}; def array = new def[] {i, l, f*d, s}; <6>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -114,12 +114,12 @@ brace_access: '[' expression ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[] x = new int[2]; int[] x = new int[2]; <1>
<2> x[0] = 2; x[0] = 2; <2>
<3> x[1] = 5; x[1] = 5; <3>
<4> int y = x[0] + x[1]; int y = x[0] + x[1]; <4>
<5> int z = 1; int z = 1; <5>
<6> int i = x[z]; int i = x[z]; <6>
---- ----
+ +
<1> declare `int[] x`; <1> declare `int[] x`;
@ -149,12 +149,12 @@ brace_access: '[' expression ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = new int[2]; def d = new int[2]; <1>
<2> d[0] = 2; d[0] = 2; <2>
<3> d[1] = 5; d[1] = 5; <3>
<4> def x = d[0] + d[1]; def x = d[0] + d[1]; <4>
<5> def y = 1; def y = 1; <5>
<6> def z = d[y]; def z = d[y]; <6>
---- ----
+ +
<1> declare `def d`; <1> declare `def d`;
@ -199,9 +199,9 @@ brace_access: '[' expression ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[][][] ia3 = new int[2][3][4]; int[][][] ia3 = new int[2][3][4]; <1>
<2> ia3[1][2][3] = 99; ia3[1][2][3] = 99; <2>
<3> int i = ia3[1][2][3]; int i = ia3[1][2][3]; <3>
---- ----
+ +
<1> declare `int[][][] ia`; <1> declare `int[][][] ia`;
@ -230,8 +230,8 @@ from an array type value.
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[] x = new int[10]; int[] x = new int[10]; <1>
<2> int l = x.length; int l = x.length; <2>
---- ----
<1> declare `int[] x`; <1> declare `int[] x`;
allocate `1-d int array` instance with `length [2]` allocate `1-d int array` instance with `length [2]`
@ -269,10 +269,10 @@ new_array: 'new' TYPE ('[' expression ']')+;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[] x = new int[5]; int[] x = new int[5]; <1>
<2> x = new int[10]; x = new int[10]; <2>
<3> int y = 2; int y = 2; <3>
<4> def z = new def[y][y*2]; def z = new def[y][y*2]; <4>
---- ----
+ +
<1> declare `int[] x`; <1> declare `int[] x`;

View File

@ -34,8 +34,8 @@ boolean_not: '!' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = !false; boolean x = !false; <1>
<2> boolean y = !x; boolean y = !x; <2>
---- ----
<1> declare `boolean x`; <1> declare `boolean x`;
boolean not `boolean false` -> `boolean true`; boolean not `boolean false` -> `boolean true`;
@ -49,8 +49,8 @@ boolean_not: '!' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def y = true; def y = true; <1>
<2> def z = !y; def z = !y; <2>
---- ----
+ +
<1> declare `def y`; <1> declare `def y`;
@ -103,9 +103,9 @@ greater_than: expression '>' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = 5 > 4; boolean x = 5 > 4; <1>
<2> double y = 6.0; double y = 6.0; <2>
<3> x = 6 > y; x = 6 > y; <3>
---- ----
+ +
<1> declare `boolean x`; <1> declare `boolean x`;
@ -123,10 +123,10 @@ greater_than: expression '>' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x = 5; int x = 5; <1>
<2> def y = 7.0; def y = 7.0; <2>
<3> def z = y > 6.5; def z = y > 6.5; <3>
<4> def a = x > y; def a = x > y; <4>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -190,9 +190,9 @@ greater_than_or_equal: expression '>=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = 5 >= 4; boolean x = 5 >= 4; <1>
<2> double y = 6.0; double y = 6.0; <2>
<3> x = 6 >= y; x = 6 >= y; <3>
---- ----
+ +
<1> declare `boolean x`; <1> declare `boolean x`;
@ -210,10 +210,10 @@ greater_than_or_equal: expression '>=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x = 5; int x = 5; <1>
<2> def y = 7.0; def y = 7.0; <2>
<3> def z = y >= 7.0; def z = y >= 7.0; <3>
<4> def a = x >= y; def a = x >= y; <4>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -277,9 +277,9 @@ less_than: expression '<' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = 5 < 4; boolean x = 5 < 4; <1>
<2> double y = 6.0; double y = 6.0; <2>
<3> x = 6 < y; x = 6 < y; <3>
---- ----
+ +
<1> declare `boolean x`; <1> declare `boolean x`;
@ -297,10 +297,10 @@ less_than: expression '<' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x = 5; int x = 5; <1>
<2> def y = 7.0; def y = 7.0; <2>
<3> def z = y < 6.5; def z = y < 6.5; <3>
<4> def a = x < y; def a = x < y; <4>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -364,9 +364,9 @@ greater_than_or_equal: expression '<=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = 5 <= 4; boolean x = 5 <= 4; <1>
<2> double y = 6.0; double y = 6.0; <2>
<3> x = 6 <= y; x = 6 <= y; <3>
---- ----
+ +
<1> declare `boolean x`; <1> declare `boolean x`;
@ -384,10 +384,10 @@ greater_than_or_equal: expression '<=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x = 5; int x = 5; <1>
<2> def y = 7.0; def y = 7.0; <2>
<3> def z = y <= 7.0; def z = y <= 7.0; <3>
<4> def a = x <= y; def a = x <= y; <4>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -436,9 +436,9 @@ instance_of: ID 'instanceof' TYPE;
+ +
[source,Painless] [source,Painless]
---- ----
<1> Map m = new HashMap(); Map m = new HashMap(); <1>
<2> boolean a = m instanceof HashMap; boolean a = m instanceof HashMap; <2>
<3> boolean b = m instanceof Map; boolean b = m instanceof Map; <3>
---- ----
+ +
<1> declare `Map m`; <1> declare `Map m`;
@ -461,9 +461,9 @@ instance_of: ID 'instanceof' TYPE;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = new ArrayList(); def d = new ArrayList(); <1>
<2> boolean a = d instanceof List; boolean a = d instanceof List; <2>
<3> boolean b = d instanceof Map; boolean b = d instanceof Map; <3>
---- ----
+ +
<1> declare `def d`; <1> declare `def d`;
@ -531,10 +531,10 @@ equality_equals: expression '==' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean a = true; boolean a = true; <1>
<2> boolean b = false; boolean b = false; <2>
<3> a = a == false; a = a == false; <3>
<4> b = a == b; b = a == b; <4>
---- ----
+ +
<1> declare `boolean a`; <1> declare `boolean a`;
@ -554,10 +554,10 @@ equality_equals: expression '==' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int a = 1; int a = 1; <1>
<2> double b = 2.0; double b = 2.0; <2>
<3> boolean c = a == b; boolean c = a == b; <3>
<4> c = 1 == a; c = 1 == a; <4>
---- ----
+ +
<1> declare `int a`; <1> declare `int a`;
@ -579,12 +579,12 @@ equality_equals: expression '==' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> List a = new ArrayList(); List a = new ArrayList(); <1>
<2> List b = new ArrayList(); List b = new ArrayList(); <2>
<3> a.add(1); a.add(1); <3>
<4> boolean c = a == b; boolean c = a == b; <4>
<5> b.add(1); b.add(1); <5>
<6> c = a == b; c = a == b; <6>
---- ----
+ +
<1> declare `List a`; <1> declare `List a`;
@ -615,12 +615,12 @@ equality_equals: expression '==' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> Object a = null; Object a = null; <1>
<2> Object b = null; Object b = null; <2>
<3> boolean c = a == null; boolean c = a == null; <3>
<4> c = a == b; c = a == b; <4>
<5> b = new Object(); b = new Object(); <5>
<6> c = a == b; c = a == b; <6>
---- ----
+ +
<1> declare `Object a`; <1> declare `Object a`;
@ -647,12 +647,12 @@ equality_equals: expression '==' expression;
+ +
[source, Painless] [source, Painless]
---- ----
<1> def a = 0; def a = 0; <1>
<2> def b = 1; def b = 1; <2>
<3> boolean c = a == b; boolean c = a == b; <3>
<4> def d = new HashMap(); def d = new HashMap(); <4>
<5> def e = new ArrayList(); def e = new ArrayList(); <5>
<6> c = d == e; c = d == e; <6>
---- ----
+ +
<1> declare `def a`; <1> declare `def a`;
@ -733,10 +733,10 @@ equality_not_equals: expression '!=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean a = true; boolean a = true; <1>
<2> boolean b = false; boolean b = false; <2>
<3> a = a != false; a = a != false; <3>
<4> b = a != b; b = a != b; <4>
---- ----
+ +
<1> declare `boolean a`; <1> declare `boolean a`;
@ -755,10 +755,10 @@ equality_not_equals: expression '!=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int a = 1; int a = 1; <1>
<2> double b = 2.0; double b = 2.0; <2>
<3> boolean c = a != b; boolean c = a != b; <3>
<4> c = 1 != a; c = 1 != a; <4>
---- ----
+ +
<1> declare `int a`; <1> declare `int a`;
@ -780,12 +780,12 @@ equality_not_equals: expression '!=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> List a = new ArrayList(); List a = new ArrayList(); <1>
<2> List b = new ArrayList(); List b = new ArrayList(); <2>
<3> a.add(1); a.add(1); <3>
<4> boolean c = a == b; boolean c = a == b; <4>
<5> b.add(1); b.add(1); <5>
<6> c = a == b; c = a == b; <6>
---- ----
+ +
<1> declare `List a`; <1> declare `List a`;
@ -818,12 +818,12 @@ equality_not_equals: expression '!=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> Object a = null; Object a = null; <1>
<2> Object b = null; Object b = null; <2>
<3> boolean c = a == null; boolean c = a == null; <3>
<4> c = a == b; c = a == b; <4>
<5> b = new Object(); b = new Object(); <5>
<6> c = a == b; c = a == b; <6>
---- ----
+ +
<1> declare `Object a`; <1> declare `Object a`;
@ -851,12 +851,12 @@ equality_not_equals: expression '!=' expression;
+ +
[source, Painless] [source, Painless]
---- ----
<1> def a = 0; def a = 0; <1>
<2> def b = 1; def b = 1; <2>
<3> boolean c = a == b; boolean c = a == b; <3>
<4> def d = new HashMap(); def d = new HashMap(); <4>
<5> def e = new ArrayList(); def e = new ArrayList(); <5>
<6> c = d == e; c = d == e; <6>
---- ----
+ +
<1> declare `def a`; <1> declare `def a`;
@ -934,11 +934,11 @@ identity_equals: expression '===' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> List a = new ArrayList(); List a = new ArrayList(); <1>
<2> List b = new ArrayList(); List b = new ArrayList(); <2>
<3> List c = a; List c = a; <3>
<4> boolean c = a === b; boolean c = a === b; <4>
<5> c = a === c; c = a === c; <5>
---- ----
+ +
<1> declare `List a`; <1> declare `List a`;
@ -969,12 +969,12 @@ identity_equals: expression '===' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> Object a = null; Object a = null; <1>
<2> Object b = null; Object b = null; <2>
<3> boolean c = a === null; boolean c = a === null; <3>
<4> c = a === b; c = a === b; <4>
<5> b = new Object(); b = new Object(); <5>
<6> c = a === b; c = a === b; <6>
---- ----
+ +
<1> declare `Object a`; <1> declare `Object a`;
@ -1000,11 +1000,11 @@ identity_equals: expression '===' expression;
+ +
[source, Painless] [source, Painless]
---- ----
<1> def a = new HashMap(); def a = new HashMap(); <1>
<2> def b = new ArrayList(); def b = new ArrayList(); <2>
<3> boolean c = a === b; boolean c = a === b; <3>
<4> b = a; b = a; <4>
<5> c = a === b; c = a === b; <5>
---- ----
+ +
<1> declare `def d`; <1> declare `def d`;
@ -1081,11 +1081,11 @@ identity_not_equals: expression '!==' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> List a = new ArrayList(); List a = new ArrayList(); <1>
<2> List b = new ArrayList(); List b = new ArrayList(); <2>
<3> List c = a; List c = a; <3>
<4> boolean c = a !== b; boolean c = a !== b; <4>
<5> c = a !== c; c = a !== c; <5>
---- ----
+ +
<1> declare `List a`; <1> declare `List a`;
@ -1116,12 +1116,12 @@ identity_not_equals: expression '!==' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> Object a = null; Object a = null; <1>
<2> Object b = null; Object b = null; <2>
<3> boolean c = a !== null; boolean c = a !== null; <3>
<4> c = a !== b; c = a !== b; <4>
<5> b = new Object(); b = new Object(); <5>
<6> c = a !== b; c = a !== b; <6>
---- ----
+ +
<1> declare `Object a`; <1> declare `Object a`;
@ -1147,11 +1147,11 @@ identity_not_equals: expression '!==' expression;
+ +
[source, Painless] [source, Painless]
---- ----
<1> def a = new HashMap(); def a = new HashMap(); <1>
<2> def b = new ArrayList(); def b = new ArrayList(); <2>
<3> boolean c = a !== b; boolean c = a !== b; <3>
<4> b = a; b = a; <4>
<5> c = a !== b; c = a !== b; <5>
---- ----
+ +
<1> declare `def d`; <1> declare `def d`;
@ -1216,9 +1216,9 @@ boolean_xor: expression '^' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = false; boolean x = false; <1>
<2> boolean y = x ^ true; boolean y = x ^ true; <2>
<3> y = y ^ x; y = y ^ x; <3>
---- ----
+ +
<1> declare `boolean x`; <1> declare `boolean x`;
@ -1236,9 +1236,9 @@ boolean_xor: expression '^' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = false; def x = false; <1>
<2> def y = x ^ true; def y = x ^ true; <2>
<3> y = y ^ x; y = y ^ x; <3>
---- ----
+ +
<1> declare `def x`; <1> declare `def x`;
@ -1292,10 +1292,10 @@ boolean_and: expression '&&' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = true; boolean x = true; <1>
<2> boolean y = x && true; boolean y = x && true; <2>
<3> x = false; x = false; <3>
<4> y = y && x; y = y && x; <4>
---- ----
+ +
<1> declare `boolean x`; <1> declare `boolean x`;
@ -1314,10 +1314,10 @@ boolean_and: expression '&&' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = true; def x = true; <1>
<2> def y = x && true; def y = x && true; <2>
<3> x = false; x = false; <3>
<4> y = y && x; y = y && x; <4>
---- ----
+ +
<1> declare `def x`; <1> declare `def x`;
@ -1372,10 +1372,10 @@ boolean_and: expression '||' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean x = false; boolean x = false; <1>
<2> boolean y = x || true; boolean y = x || true; <2>
<3> y = false; y = false; <3>
<4> y = y || x; y = y || x; <4>
---- ----
+ +
<1> declare `boolean x`; <1> declare `boolean x`;
@ -1394,10 +1394,10 @@ boolean_and: expression '||' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = false; def x = false; <1>
<2> def y = x || true; def y = x || true; <2>
<3> y = false; y = false; <3>
<4> y = y || x; y = y || x; <4>
---- ----
+ +
<1> declare `def x`; <1> declare `def x`;

View File

@ -22,8 +22,8 @@ precedence: '(' expression ')';
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x = (5+4)*6; int x = (5+4)*6; <1>
<2> int y = 12/(x-50); int y = 12/(x-50); <2>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -59,11 +59,11 @@ function_call: ID '(' ( expression (',' expression)* )? ')'';
+ +
[source,Painless] [source,Painless]
---- ----
<1> int add(int x, int y) { int add(int x, int y) { <1>
return x + y; return x + y;
} }
<2> int z = add(1, 2); int z = add(1, 2); <2>
---- ----
+ +
<1> define function `add` that returns `int` and has parameters (`int x`, <1> define function `add` that returns `int` and has parameters (`int x`,
@ -128,10 +128,10 @@ occur.
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean b = true; boolean b = true; <1>
<2> int x = b ? 1 : 2; int x = b ? 1 : 2; <2>
<3> List y = x > 1 ? new ArrayList() : null; List y = x > 1 ? new ArrayList() : null; <3>
<4> def z = x < 2 ? x : 2.0; def z = x < 2 ? x : 2.0; <4>
---- ----
+ +
<1> declare `boolean b`; <1> declare `boolean b`;
@ -195,10 +195,10 @@ non-static member fields:
+ +
[source,Painless] [source,Painless]
---- ----
<1> Example example = new Example(); Example example = new Example(); <1>
<2> example.x = 1; example.x = 1; <2>
<3> example.y = 2.0; example.y = 2.0; <3>
<4> example.z = new ArrayList(); example.z = new ArrayList(); <4>
---- ----
+ +
<1> declare `Example example`; <1> declare `Example example`;
@ -218,9 +218,9 @@ non-static member fields:
+ +
[source,Painless] [source,Painless]
---- ----
<1> Example example = new Example(); Example example = new Example(); <1>
<2> example.x = 1; example.x = 1; <2>
<3> example.y = example.x; example.y = example.x; <3>
---- ----
+ +
<1> declare `Example example`; <1> declare `Example example`;
@ -297,18 +297,18 @@ operators.
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 10; int i = 10; <1>
<2> i *= 2; i *= 2; <2>
<3> i /= 5; i /= 5; <3>
<4> i %= 3; i %= 3; <4>
<5> i += 5; i += 5; <5>
<6> i -= 5; i -= 5; <6>
<7> i <<= 2; i <<= 2; <7>
<8> i >>= 1; i >>= 1; <8>
<9> i >>>= 1; i >>>= 1; <9>
<10> i &= 15; i &= 15; <10>
<11> i ^= 12; i ^= 12; <11>
<12> i |= 2; i |= 2; <12>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -362,10 +362,10 @@ operators.
+ +
[source,Painless] [source,Painless]
---- ----
<1> boolean b = true; boolean b = true; <1>
<2> b &= false; b &= false; <2>
<3> b ^= false; b ^= false; <3>
<4> b |= true; b |= true; <4>
---- ----
+ +
<1> declare `boolean b`; <1> declare `boolean b`;
@ -387,8 +387,8 @@ operators.
+ +
[source,Painless] [source,Painless]
---- ----
<1> String s = 'compound'; String s = 'compound'; <1>
<2> s += ' assignment'; s += ' assignment'; <2>
---- ----
<1> declare `String s`; <1> declare `String s`;
store `String 'compound'` to `s`; store `String 'compound'` to `s`;
@ -402,8 +402,8 @@ operators.
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 1; def x = 1; <1>
<2> x += 2; x += 2; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
implicit cast `int 1` to `def`; implicit cast `int 1` to `def`;
@ -419,8 +419,8 @@ operators.
+ +
[source,Painless] [source,Painless]
---- ----
<1> byte b = 1; byte b = 1; <1>
<2> b += 2; b += 2; <2>
---- ----
<1> declare `byte b`; <1> declare `byte b`;
store `byte 1` to `x`; store `byte 1` to `x`;

View File

@ -43,11 +43,11 @@ post_increment: ( variable | field ) '++';
+ +
[source,Painless] [source,Painless]
---- ----
<1> short i = 0; short i = 0; <1>
<2> i++; i++; <2>
<3> long j = 1; long j = 1; <3>
<4> long k; long k; <4>
<5> k = j++; k = j++; <5>
---- ----
+ +
<1> declare `short i`; <1> declare `short i`;
@ -71,8 +71,8 @@ post_increment: ( variable | field ) '++';
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 1; def x = 1; <1>
<2> x++; x++; <2>
---- ----
+ +
<1> declare `def x`; <1> declare `def x`;
@ -126,11 +126,11 @@ post_decrement: ( variable | field ) '--';
+ +
[source,Painless] [source,Painless]
---- ----
<1> short i = 0; short i = 0; <1>
<2> i--; i--; <2>
<3> long j = 1; long j = 1; <3>
<4> long k; long k; <4>
<5> k = j--; k = j--; <5>
---- ----
+ +
<1> declare `short i`; <1> declare `short i`;
@ -154,8 +154,8 @@ post_decrement: ( variable | field ) '--';
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 1; def x = 1; <1>
<2> x--; x--; <2>
---- ----
+ +
<1> declare `def x`; <1> declare `def x`;
@ -209,11 +209,11 @@ pre_increment: '++' ( variable | field );
+ +
[source,Painless] [source,Painless]
---- ----
<1> short i = 0; short i = 0; <1>
<2> ++i; ++i; <2>
<3> long j = 1; long j = 1; <3>
<4> long k; long k; <4>
<5> k = ++j; k = ++j; <5>
---- ----
+ +
<1> declare `short i`; <1> declare `short i`;
@ -237,8 +237,8 @@ pre_increment: '++' ( variable | field );
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 1; def x = 1; <1>
<2> ++x; ++x; <2>
---- ----
+ +
<1> declare `def x`; <1> declare `def x`;
@ -292,11 +292,11 @@ pre_increment: '--' ( variable | field );
+ +
[source,Painless] [source,Painless]
---- ----
<1> short i = 0; short i = 0; <1>
<2> --i; --i; <2>
<3> long j = 1; long j = 1; <3>
<4> long k; long k; <4>
<5> k = --j; k = --j; <5>
---- ----
+ +
<1> declare `short i`; <1> declare `short i`;
@ -320,8 +320,8 @@ pre_increment: '--' ( variable | field );
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 1; def x = 1; <1>
<2> --x; --x; <2>
---- ----
+ +
<1> declare `def x`; <1> declare `def x`;
@ -356,8 +356,8 @@ unary_positive: '+' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x = +1; int x = +1; <1>
<2> long y = +x; long y = +x; <2>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -373,8 +373,8 @@ unary_positive: '+' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def z = +1; def z = +1; <1>
<2> int i = +z; int i = +z; <2>
---- ----
<1> declare `def z`; <1> declare `def z`;
identity `int 1` -> `int 1`; identity `int 1` -> `int 1`;
@ -408,8 +408,8 @@ unary_negative: '-' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x = -1; int x = -1; <1>
<2> long y = -x; long y = -x; <2>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -425,8 +425,8 @@ unary_negative: '-' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def z = -1; def z = -1; <1>
<2> int i = -z; int i = -z; <2>
---- ----
<1> declare `def z`; <1> declare `def z`;
negate `int 1` -> `int -1`; negate `int 1` -> `int -1`;
@ -484,9 +484,9 @@ bitwise_not: '~' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> byte b = 1; byte b = 1; <1>
<2> int i = ~b; int i = ~b; <2>
<3> long l = ~i; long l = ~i; <3>
---- ----
+ +
<1> declare `byte x`; <1> declare `byte x`;
@ -506,8 +506,8 @@ bitwise_not: '~' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = 1; def d = 1; <1>
<2> def e = ~d; def e = ~d; <2>
---- ----
+ +
<1> declare `def d`; <1> declare `def d`;
@ -559,8 +559,8 @@ multiplication: expression '*' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 5*4; int i = 5*4; <1>
<2> double d = i*7.0; double d = i*7.0; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -577,8 +577,8 @@ multiplication: expression '*' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 5*4; def x = 5*4; <1>
<2> def y = x*2; def y = x*2; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
multiply `int 5` by `int 4` -> `int 20`; multiply `int 5` by `int 4` -> `int 20`;
@ -632,8 +632,8 @@ division: expression '/' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 29/4; int i = 29/4; <1>
<2> double d = i/7.0; double d = i/7.0; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -650,8 +650,8 @@ division: expression '/' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 5/4; def x = 5/4; <1>
<2> def y = x/2; def y = x/2; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
divide `int 5` by `int 4` -> `int 1`; divide `int 5` by `int 4` -> `int 1`;
@ -703,8 +703,8 @@ remainder: expression '%' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 29%4; int i = 29%4; <1>
<2> double d = i%7.0; double d = i%7.0; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -721,8 +721,8 @@ remainder: expression '%' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 5%4; def x = 5%4; <1>
<2> def y = x%2; def y = x%2; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
remainder `int 5` by `int 4` -> `int 1`; remainder `int 5` by `int 4` -> `int 1`;
@ -773,8 +773,8 @@ addition: expression '+' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 29+4; int i = 29+4; <1>
<2> double d = i+7.0; double d = i+7.0; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -791,8 +791,8 @@ addition: expression '+' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 5+4; def x = 5+4; <1>
<2> def y = x+2; def y = x+2; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
add `int 5` and `int 4` -> `int 9`; add `int 5` and `int 4` -> `int 9`;
@ -844,8 +844,8 @@ subtraction: expression '-' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 29-4; int i = 29-4; <1>
<2> double d = i-7.5; double d = i-7.5; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -862,8 +862,8 @@ subtraction: expression '-' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 5-4; def x = 5-4; <1>
<2> def y = x-2; def y = x-2; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
subtract `int 4` and `int 5` -> `int 1`; subtract `int 4` and `int 5` -> `int 1`;
@ -918,8 +918,8 @@ below. The right-hand side integer type value is always implicitly cast to an
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 4 << 1; int i = 4 << 1; <1>
<2> long l = i << 2L; long l = i << 2L; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -936,8 +936,8 @@ below. The right-hand side integer type value is always implicitly cast to an
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 4 << 2; def x = 4 << 2; <1>
<2> def y = x << 1; def y = x << 1; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
left shift `int 4` by `int 2` -> `int 16`; left shift `int 4` by `int 2` -> `int 16`;
@ -993,8 +993,8 @@ below. The right-hand side integer type value is always implicitly cast to an
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 32 >> 1; int i = 32 >> 1; <1>
<2> long l = i >> 2L; long l = i >> 2L; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -1011,8 +1011,8 @@ below. The right-hand side integer type value is always implicitly cast to an
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 16 >> 2; def x = 16 >> 2; <1>
<2> def y = x >> 1; def y = x >> 1; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
right shift `int 16` by `int 2` -> `int 4`; right shift `int 16` by `int 2` -> `int 4`;
@ -1068,8 +1068,8 @@ below. The right-hand side integer type value is always implicitly cast to an
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = -1 >>> 29; int i = -1 >>> 29; <1>
<2> long l = i >>> 2L; long l = i >>> 2L; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -1086,8 +1086,8 @@ below. The right-hand side integer type value is always implicitly cast to an
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 16 >>> 2; def x = 16 >>> 2; <1>
<2> def y = x >>> 1; def y = x >>> 1; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
unsigned right shift `int 16` by `int 2` -> `int 4`; unsigned right shift `int 16` by `int 2` -> `int 4`;
@ -1146,8 +1146,8 @@ bitwise_and: expression '&' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 5 & 6; int i = 5 & 6; <1>
<2> long l = i & 5L; long l = i & 5L; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -1164,8 +1164,8 @@ bitwise_and: expression '&' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 15 & 6; def x = 15 & 6; <1>
<2> def y = x & 5; def y = x & 5; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
bitwise and `int 15` and `int 6` -> `int 6`; bitwise and `int 15` and `int 6` -> `int 6`;
@ -1226,8 +1226,8 @@ bitwise_and: expression '^' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 5 ^ 6; int i = 5 ^ 6; <1>
<2> long l = i ^ 5L; long l = i ^ 5L; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -1244,8 +1244,8 @@ bitwise_and: expression '^' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 15 ^ 6; def x = 15 ^ 6; <1>
<2> def y = x ^ 5; def y = x ^ 5; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
bitwise xor `int 15` and `int 6` -> `int 9`; bitwise xor `int 15` and `int 6` -> `int 9`;
@ -1306,8 +1306,8 @@ bitwise_and: expression '|' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 5 | 6; int i = 5 | 6; <1>
<2> long l = i | 8L; long l = i | 8L; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -1324,8 +1324,8 @@ bitwise_and: expression '|' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def x = 5 ^ 6; def x = 5 ^ 6; <1>
<2> def y = x ^ 8; def y = x ^ 8; <2>
---- ----
<1> declare `def x`; <1> declare `def x`;
bitwise or `int 5` and `int 6` -> `int 7`; bitwise or `int 5` and `int 6` -> `int 7`;

View File

@ -38,12 +38,12 @@ arguments: '(' (expression (',' expression)*)? ')';
+ +
[source,Painless] [source,Painless]
---- ----
<1> Map m = new HashMap(); Map m = new HashMap(); <1>
<2> m.put(1, 2); m.put(1, 2); <2>
<3> int z = m.get(1); int z = m.get(1); <3>
<4> def d = new ArrayList(); def d = new ArrayList(); <4>
<5> d.add(1); d.add(1); <5>
<6> int i = Integer.parseInt(d.get(0).toString()); int i = Integer.parseInt(d.get(0).toString()); <6>
---- ----
+ +
<1> declare `Map m`; <1> declare `Map m`;
@ -111,12 +111,12 @@ non-static member fields:
+ +
[source,Painless] [source,Painless]
---- ----
<1> Example example = new Example(); Example example = new Example(); <1>
<2> example.x = 1; example.x = 1; <2>
<3> example.y = example.x; example.y = example.x; <3>
<4> example.z = new ArrayList(); example.z = new ArrayList(); <4>
<5> example.z.add(1); example.z.add(1); <5>
<6> example.x = example.z.get(0); example.x = example.z.get(0); <6>
---- ----
+ +
<1> declare `Example example`; <1> declare `Example example`;
@ -192,8 +192,8 @@ non-static member fields:
+ +
[source,Painless] [source,Painless]
---- ----
<1> Example example = new Example(); Example example = new Example(); <1>
<2> List x = example?.factory(); List x = example?.factory(); <2>
---- ----
+ +
<1> declare `Example example`; <1> declare `Example example`;
@ -208,8 +208,8 @@ non-static member fields:
+ +
[source,Painless] [source,Painless]
---- ----
<1> Example example = null; Example example = null; <1>
<2> List x = example?.x; List x = example?.x; <2>
---- ----
<1> declare `Example example`; <1> declare `Example example`;
store `null` to `example` store `null` to `example`
@ -242,7 +242,7 @@ list_initialization: '[' expression (',' expression)* ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> List empty = []; List empty = []; <1>
---- ----
+ +
<1> declare `List empty`; <1> declare `List empty`;
@ -254,7 +254,7 @@ list_initialization: '[' expression (',' expression)* ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> List list = [1, 2, 3]; List list = [1, 2, 3]; <1>
---- ----
+ +
<1> declare `List list`; <1> declare `List list`;
@ -269,12 +269,12 @@ list_initialization: '[' expression (',' expression)* ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 1; int i = 1; <1>
<2> long l = 2L; long l = 2L; <2>
<3> float f = 3.0F; float f = 3.0F; <3>
<4> double d = 4.0; double d = 4.0; <4>
<5> String s = "5"; String s = "5"; <5>
<6> List list = [i, l, f*d, s]; List list = [i, l, f*d, s]; <6>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -329,15 +329,15 @@ list_access: '[' expression ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> List list = new ArrayList(); List list = new ArrayList(); <1>
<2> list.add(1); list.add(1); <2>
<3> list.add(2); list.add(2); <3>
<4> list.add(3); list.add(3); <4>
<5> list[0] = 2; list[0] = 2; <5>
<6> list[1] = 5; list[1] = 5; <6>
<7> int x = list[0] + list[1]; int x = list[0] + list[1]; <7>
<8> int y = 1; int y = 1; <8>
<9> int z = list[y]; int z = list[y]; <9>
---- ----
+ +
<1> declare `List list`; <1> declare `List list`;
@ -376,15 +376,15 @@ list_access: '[' expression ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = new ArrayList(); def d = new ArrayList(); <1>
<2> d.add(1); d.add(1); <2>
<3> d.add(2); d.add(2); <3>
<4> d.add(3); d.add(3); <4>
<5> d[0] = 2; d[0] = 2; <5>
<6> d[1] = 5; d[1] = 5; <6>
<7> def x = d[0] + d[1]; def x = d[0] + d[1]; <7>
<8> def y = 1; def y = 1; <8>
<9> def z = d[y]; def z = d[y]; <9>
---- ----
+ +
<1> declare `List d`; <1> declare `List d`;
@ -449,7 +449,7 @@ key_pair: expression ':' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> Map empty = [:]; Map empty = [:]; <1>
---- ----
+ +
<1> declare `Map empty`; <1> declare `Map empty`;
@ -461,7 +461,7 @@ key_pair: expression ':' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> Map map = [1:2, 3:4, 5:6]; Map map = [1:2, 3:4, 5:6]; <1>
---- ----
+ +
<1> declare `Map map`; <1> declare `Map map`;
@ -476,13 +476,13 @@ key_pair: expression ':' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> byte b = 0; byte b = 0; <1>
<2> int i = 1; int i = 1; <2>
<3> long l = 2L; long l = 2L; <3>
<4> float f = 3.0F; float f = 3.0F; <4>
<5> double d = 4.0; double d = 4.0; <5>
<6> String s = "5"; String s = "5"; <6>
<7> Map map = [b:i, l:f*d, d:s]; Map map = [b:i, l:f*d, d:s]; <7>
---- ----
+ +
<1> declare `byte b`; <1> declare `byte b`;
@ -538,12 +538,12 @@ map_access: '[' expression ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> Map map = new HashMap(); Map map = new HashMap(); <1>
<2> map['value2'] = 2; map['value2'] = 2; <2>
<3> map['value5'] = 5; map['value5'] = 5; <3>
<4> int x = map['value2'] + map['value5']; int x = map['value2'] + map['value5']; <4>
<5> String y = 'value5'; String y = 'value5'; <5>
<6> int z = x[z]; int z = x[z]; <6>
---- ----
+ +
<1> declare `Map map`; <1> declare `Map map`;
@ -576,12 +576,12 @@ map_access: '[' expression ']'
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = new HashMap(); def d = new HashMap(); <1>
<2> d['value2'] = 2; d['value2'] = 2; <2>
<3> d['value5'] = 5; d['value5'] = 5; <3>
<4> int x = d['value2'] + d['value5']; int x = d['value2'] + d['value5']; <4>
<5> String y = 'value5'; String y = 'value5'; <5>
<6> def z = d[y]; def z = d[y]; <6>
---- ----
+ +
<1> declare `def d`; <1> declare `def d`;
@ -649,9 +649,9 @@ new_instance: 'new' TYPE '(' (expression (',' expression)*)? ')';
[source,Painless] [source,Painless]
---- ----
<1> Map m = new HashMap(); Map m = new HashMap(); <1>
<2> def d = new ArrayList(); def d = new ArrayList(); <2>
<3> def e = new HashMap(m); def e = new HashMap(m); <3>
---- ----
<1> declare `Map m`; <1> declare `Map m`;
allocate `HashMap` instance -> `HashMap reference`; allocate `HashMap` instance -> `HashMap reference`;
@ -687,9 +687,9 @@ concatenate: expression '+' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> String x = "con"; String x = "con"; <1>
<2> String y = x + "cat"; String y = x + "cat"; <2>
<3> String z = 4 + 5 + x; String z = 4 + 5 + x; <3>
---- ----
+ +
<1> declare `String x`; <1> declare `String x`;
@ -709,8 +709,8 @@ concatenate: expression '+' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> def d = 2; def d = 2; <1>
<2> d = "con" + d + "cat"; d = "con" + d + "cat"; <2>
---- ----
+ +
<1> declare `def`; <1> declare `def`;
@ -749,10 +749,10 @@ elvis: expression '?:' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> List x = new ArrayList(); List x = new ArrayList(); <1>
<2> List y = x ?: new ArrayList(); List y = x ?: new ArrayList(); <2>
<3> y = null; y = null; <3>
<4> List z = y ?: new ArrayList(); List z = y ?: new ArrayList(); <4>
---- ----
+ +
<1> declare `List x`; <1> declare `List x`;

View File

@ -77,9 +77,9 @@ logical quantity with two possible values of `true` and `false`
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 1; int i = 1; <1>
<2> double d; double d; <2>
<3> boolean b = true; boolean b = true; <3>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -93,8 +93,8 @@ logical quantity with two possible values of `true` and `false`
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 1; int i = 1; <1>
<2> i.toString(); i.toString(); <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -193,9 +193,9 @@ relationships.
+ +
[source,Painless] [source,Painless]
---- ----
<1> List l = new ArrayList(); List l = new ArrayList(); <1>
<2> l.add(1); l.add(1); <2>
<3> int i = l.get(0) + 2; int i = l.get(0) + 2; <3>
---- ----
+ +
<1> declare `List l`; <1> declare `List l`;
@ -216,11 +216,11 @@ relationships.
+ +
[source,Painless] [source,Painless]
---- ----
<1> List l0 = new ArrayList(); List l0 = new ArrayList(); <1>
<2> List l1 = l0; List l1 = l0; <2>
<3> l0.add(1); l0.add(1); <3>
<4> l1.add(2); l1.add(2); <4>
<5> int i = l1.get(0) + l0.get(1); int i = l1.get(0) + l0.get(1); <5>
---- ----
+ +
<1> declare `List l0`; <1> declare `List l0`;
@ -251,8 +251,8 @@ relationships.
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = Integer.MAX_VALUE; int i = Integer.MAX_VALUE; <1>
<2> long l = Long.parseLong("123L"); long l = Long.parseLong("123L"); <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -292,9 +292,9 @@ types and reference types directly when performance is critical.
+ +
[source,Painless] [source,Painless]
---- ----
<1> def dp = 1; def dp = 1; <1>
<2> def dr = new ArrayList(); def dr = new ArrayList(); <2>
<3> dr = dp; dr = dp; <3>
---- ----
+ +
<1> declare `def dp`; <1> declare `def dp`;
@ -312,9 +312,9 @@ types and reference types directly when performance is critical.
+ +
[source,Painless] [source,Painless]
---- ----
<1> Object l = new ArrayList(); Object l = new ArrayList(); <1>
<2> def d = l; def d = l; <2>
<3> d.ensureCapacity(10); d.ensureCapacity(10); <3>
---- ----
+ +
<1> declare `Object l`; <1> declare `Object l`;
@ -348,10 +348,10 @@ instances.
+ +
[source,Painless] [source,Painless]
---- ----
<1> String r = "some text"; String r = "some text"; <1>
<2> String s = 'some text'; String s = 'some text'; <2>
<3> String t = new String("some text"); String t = new String("some text"); <3>
<4> String u; String u; <4>
---- ----
+ +
<1> declare `String r`; <1> declare `String r`;
@ -425,11 +425,11 @@ type `int[]`. And each element in the 1st dimension, `d-1` is the array type
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[] x; int[] x; <1>
<2> float[] y = new float[10]; float[] y = new float[10]; <2>
<3> def z = new float[5]; def z = new float[5]; <3>
<4> y[9] = 1.0F; y[9] = 1.0F; <4>
<5> z[0] = y[9]; z[0] = y[9]; <5>
---- ----
+ +
<1> declare `int[] x`; <1> declare `int[] x`;
@ -456,9 +456,9 @@ type `int[]`. And each element in the 1st dimension, `d-1` is the array type
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[][][] ia3 = new int[2][3][4]; int[][][] ia3 = new int[2][3][4]; <1>
<2> ia3[1][2][3] = 99; ia3[1][2][3] = 99; <2>
<3> int i = ia3[1][2][3]; int i = ia3[1][2][3]; <3>
---- ----
+ +
<1> declare `int[][][] ia`; <1> declare `int[][][] ia`;

View File

@ -36,13 +36,13 @@ assignment: '=' expression;
+ +
[source,Painless] [source,Painless]
---- ----
<1> int x; int x; <1>
<2> List y; List y; <2>
<3> int x, y = 5, z; int x, y = 5, z; <3>
<4> def d; def d; <4>
<5> int i = 10; int i = 10; <5>
<6> float[] f; float[] f; <6>
<7> Map[][] m; Map[][] m; <7>
---- ----
+ +
<1> declare `int x`; <1> declare `int x`;
@ -90,8 +90,8 @@ assignment: ID '=' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i; int i; <1>
<2> i = 10; i = 10; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -102,8 +102,8 @@ assignment: ID '=' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 10; int i = 10; <1>
<2> double j = 2.0; double j = 2.0; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -115,8 +115,8 @@ assignment: ID '=' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> int i = 10; int i = 10; <1>
<2> int j = i; int j = i; <2>
---- ----
+ +
<1> declare `int i`; <1> declare `int i`;
@ -130,8 +130,8 @@ assignment: ID '=' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> ArrayList l = new ArrayList(); ArrayList l = new ArrayList(); <1>
<2> Map m = new HashMap(); Map m = new HashMap(); <2>
---- ----
+ +
<1> declare `ArrayList l`; <1> declare `ArrayList l`;
@ -146,10 +146,10 @@ assignment: ID '=' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> List l = new ArrayList(); List l = new ArrayList(); <1>
<2> List k = l; List k = l; <2>
<3> List m; List m; <3>
<4> m = k; m = k; <4>
---- ----
+ +
<1> declare `List l`; <1> declare `List l`;
@ -171,13 +171,13 @@ assignment: ID '=' expression
+ +
[source,Painless] [source,Painless]
---- ----
<1> int[] ia1; int[] ia1; <1>
<2> ia1 = new int[2]; ia1 = new int[2]; <2>
<3> ia1[0] = 1; ia1[0] = 1; <3>
<4> int[] ib1 = ia1; int[] ib1 = ia1; <4>
<5> int[][] ic2 = new int[2][5]; int[][] ic2 = new int[2][5]; <5>
<6> ic2[1][3] = 2; ic2[1][3] = 2; <6>
<7> ic2[0] = ia1; ic2[0] = ia1; <7>
---- ----
+ +
<1> declare `int[] ia1`; <1> declare `int[] ia1`;