Skip to content

Commit 3e6489a

Browse files
committed
Painless: Docs Clean Up (#29592)
As part of the lang spec: separated identifiers into its own section, and cleaned up variables section.
1 parent 4ac62af commit 3e6489a

7 files changed

+187
-148
lines changed

docs/painless/painless-comments.asciidoc

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[[painless-comments]]
22
=== Comments
33

4-
Painless supports both single-line and multi-line comments. Comments can be
5-
included anywhere within a script. Use the `//` token anywhere on a line to
6-
specify a single-line comment. All characters from the `//` token to the end
7-
of the line are ignored. Use an opening `/*` token and a closing `*/` token
8-
to specify a multi-line comment. Multi-line comments can start anywhere on a
9-
line, and all characters in between the `/*` token and `*/` token are ignored.
4+
Use the `//` token anywhere on a line to specify a single-line comment. All
5+
characters from the `//` token to the end of the line are ignored. Use an
6+
opening `/*` token and a closing `*/` token to specify a multi-line comment.
7+
Multi-line comments can start anywhere on a line, and all characters in between
8+
the `/*` token and `*/` token are ignored. Comments can be included anywhere
9+
within a script.
1010

1111
*Grammar*
1212
[source,ANTLR4]
@@ -17,17 +17,17 @@ MULTI_LINE_COMMENT: '/*' .*? '*/';
1717

1818
*Examples*
1919

20-
Single-line comments.
21-
20+
* Single-line comments.
21+
+
2222
[source,Painless]
2323
----
2424
// single-line comment
2525
2626
int value; // single-line comment
2727
----
28-
29-
Multi-line comments.
30-
28+
+
29+
* Multi-line comments.
30+
+
3131
[source,Painless]
3232
----
3333
/* multi-
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[[painless-identifiers]]
2+
=== Identifiers
3+
4+
Specify identifiers to <<declaration, declare>>, <<assignment, assign>>, and
5+
<<painless-operators, use>> variables, <<dot-operator, access fields>>, and
6+
<<dot-operator, call methods>>. <<painless-keywords, Keywords>> and
7+
<<painless-types, types>> cannot be used as identifiers.
8+
9+
*Grammar*
10+
[source,ANTLR4]
11+
----
12+
ID: [_a-zA-Z] [_a-zA-Z-0-9]*;
13+
----
14+
15+
*Examples*
16+
17+
* Variations of identifiers.
18+
+
19+
[source,Painless]
20+
----
21+
a
22+
Z
23+
id
24+
list
25+
list0
26+
MAP25
27+
_map25
28+
Map_25
29+
----

docs/painless/painless-keywords.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
=== Keywords
33

44
The keywords in the table below are reserved for built-in language
5-
features. These keywords cannot be used as <<identifiers, identifiers>> or
6-
<<painless-types, types>>.
5+
features. These keywords cannot be used as
6+
<<painless-identifiers, identifiers>> or <<painless-types, types>>.
77

88
[cols="^1,^1,^1,^1,^1"]
99
|====

docs/painless/painless-lang-spec.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ include::painless-keywords.asciidoc[]
2323

2424
include::painless-literals.asciidoc[]
2525

26+
include::painless-identifiers.asciidoc[]
27+
2628
include::painless-variables.asciidoc[]
2729

2830
include::painless-types.asciidoc[]

docs/painless/painless-literals.asciidoc

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@ HEX: '-'? '0' [xX] [0-9a-fA-F]+ [lL]?;
2424

2525
*Examples*
2626

27-
Integer literals.
28-
27+
* Integer literals.
28+
+
2929
[source,Painless]
3030
----
31-
0 <1>
32-
0D <2>
33-
1234L <3>
34-
-90f <4>
35-
-022 <5>
36-
0xF2A <6>
31+
<1> 0
32+
<2> 0D
33+
<3> 1234L
34+
<4> -90f
35+
<5> -022
36+
<6> 0xF2A
3737
----
38-
38+
+
3939
<1> `int 0`
4040
<2> `double 0.0`
4141
<3> `long 1234`
@@ -61,17 +61,17 @@ EXPONENT: ( [eE] [+\-]? [0-9]+ );
6161

6262
*Examples*
6363

64-
Floating point literals.
65-
64+
* Floating point literals.
65+
+
6666
[source,Painless]
6767
----
68-
0.0 <1>
69-
1E6 <2>
70-
0.977777 <3>
71-
-126.34 <4>
72-
89.9F <5>
68+
<1> 0.0
69+
<2> 1E6
70+
<3> 0.977777
71+
<4> -126.34
72+
<5> 89.9F
7373
----
74-
74+
+
7575
<1> `double 0.0`
7676
<2> `double 1000000.0` in exponent notation
7777
<3> `double 0.977777`
@@ -81,12 +81,11 @@ Floating point literals.
8181
[[strings]]
8282
==== Strings
8383

84-
Use string literals to specify string values of the
85-
<<string-type, String type>> with either single-quotes or double-quotes.
86-
Use a `\"` token to include a double-quote as part of a double-quoted string
87-
literal. Use a `\'` token to include a single-quote as part of a single-quoted
88-
string literal. Use a `\\` token to include a backslash as part of any string
89-
literal.
84+
Use string literals to specify <<string-type, String>> values with
85+
either single-quotes or double-quotes. Use a `\"` token to include a
86+
double-quote as part of a double-quoted string literal. Use a `\'` token to
87+
include a single-quote as part of a single-quoted string literal. Use a `\\`
88+
token to include a backslash as part of any string literal.
9089

9190
*Grammar*
9291
[source,ANTLR4]
@@ -97,22 +96,22 @@ STRING: ( '"' ( '\\"' | '\\\\' | ~[\\"] )*? '"' )
9796

9897
*Examples*
9998

100-
String literals using single-quotes.
101-
99+
* String literals using single-quotes.
100+
+
102101
[source,Painless]
103102
----
104103
'single-quoted string literal'
105-
'\'single-quoted string with escaped single-quotes\' and backslash \\'
106-
'single-quoted string with non-escaped "double-quotes"'
104+
'\'single-quoted with escaped single-quotes\' and backslash \\'
105+
'single-quoted with non-escaped "double-quotes"'
107106
----
108-
109-
String literals using double-quotes.
110-
107+
+
108+
* String literals using double-quotes.
109+
+
111110
[source,Painless]
112111
----
113112
"double-quoted string literal"
114-
"\"double-quoted string with escaped double-quotes\" and backslash: \\"
115-
"double-quoted string with non-escaped 'single-quotes'"
113+
"\"double-quoted with escaped double-quotes\" and backslash: \\"
114+
"double-quoted with non-escaped 'single-quotes'"
116115
----
117116

118117
[[characters]]
@@ -126,16 +125,16 @@ or an error will occur.
126125

127126
*Examples*
128127

129-
Casting string literals into <<primitive-types, char>> values.
130-
128+
* Casting string literals into <<primitive-types, char>> values.
129+
+
131130
[source,Painless]
132131
----
133132
(char)"C"
134133
(char)'c'
135134
----
136-
137-
Casting a <<string-type, String>> value into a <<primitive-types, char>> value.
138-
135+
+
136+
* Casting a <<string-type, String>> value into a <<primitive-types, char>> value.
137+
+
139138
[source,Painless]
140139
----
141140
String s = "s";

docs/painless/painless-operators.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ e = ~d; // sets e the negation of d
704704

705705
The cast operator can be used to explicitly convert one type to another. See casting [MARK] for more information.
706706

707+
[[constructor-call]]
707708
==== Constructor Call
708709

709710
A constructor call is a special type of method call [MARK] used to allocate a reference type instance using the new operator. The format is the new operator followed by a type, an opening parenthesis, arguments if any, and a closing parenthesis. Arguments are a series of zero-to-many expressions delimited by commas. Auto-boxing and auto-unboxing will be applied automatically for arguments passed into a constructor call. See boxing and unboxing [MARK] for more information on this topic. Constructor argument types can always be resolved at run-time; if appropriate type conversions (casting) cannot be applied an error will occur. Once a reference type instance has been allocated, its members may be used as part of other expressions.

0 commit comments

Comments
 (0)