Skip to content

Painless: Restructure Spec Documentation #31013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 99 commits into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
153d376
Separate identifiers into its own section. Clean up variables.
jdconrad Apr 17, 2018
6729d5f
More docs.
jdconrad Apr 18, 2018
84048e4
Merge branch 'master' into docs1
jdconrad Apr 18, 2018
10fca6c
Merge branch 'master' into docs1
jdconrad Apr 18, 2018
c2c3448
Modify language used to describe shallow copies.
jdconrad Apr 19, 2018
1cdf013
Move examples into lists to make sections flow better when multiple
jdconrad Apr 19, 2018
862962b
Update primitive types.
jdconrad Apr 20, 2018
73883ac
Cleaned up reference types.
jdconrad Apr 24, 2018
7dfb034
Clean up dynamic types.
jdconrad Apr 24, 2018
75f1498
String and void type clean up.
jdconrad Apr 25, 2018
f75d50e
Merge branch 'master' into docs2
jdconrad Apr 25, 2018
956a188
Merge branch 'master' into docs2
jdconrad Apr 27, 2018
bce78ed
Fixes.
jdconrad Apr 28, 2018
b034cff
Merge branch 'master' into docs2
jdconrad Apr 30, 2018
e82a1e0
Clean up types section.
jdconrad May 1, 2018
1da1704
Merge branch 'master' into docs2
jdconrad May 1, 2018
48b3aee
Merge branch 'master' into docs3
jdconrad May 2, 2018
8bc0c74
Some casting and example clean up.
jdconrad May 4, 2018
275c2e7
Merge branch 'master' into docs3
jdconrad May 4, 2018
00ba531
Updated examples.
jdconrad May 4, 2018
7bcd114
More changes.
jdconrad May 7, 2018
84ea43d
Merge branch 'master' into docs3
jdconrad May 8, 2018
1cf2f0b
Merge branch 'master' into docs3
jdconrad May 9, 2018
68059ae
More example clean up.
jdconrad May 9, 2018
73a24f0
More casting clean up.
jdconrad May 9, 2018
c3fcd67
More clean up.
jdconrad May 10, 2018
19abc56
More changes.
jdconrad May 14, 2018
00cf5df
Merge branch 'master' into docs3
jdconrad May 14, 2018
0cb3e66
More fixes.
jdconrad May 14, 2018
bc4509f
Merge branch 'master' into docs3
jdconrad May 14, 2018
507ac48
More example clean up.
jdconrad May 15, 2018
7ad4ebb
More changes.
jdconrad May 15, 2018
a9c941e
Finished promotion and boxing/unboxing.
jdconrad May 15, 2018
0007d26
Merge branch 'master' into docs2
jdconrad May 15, 2018
988fc23
Cleaned up casting basic on PR comments.
jdconrad May 19, 2018
b95ce25
More changes.
jdconrad May 21, 2018
a8ed00b
Merge branch 'master' into docs2
jdconrad May 21, 2018
7b73010
More fixes.
jdconrad May 21, 2018
8fc4566
Fixed casting and types based on PR feedback.
jdconrad May 22, 2018
ca2bb83
Cleaned up more.
jdconrad May 22, 2018
ae1ae75
Extra blank lines at end of docs.
jdconrad May 22, 2018
a5cc47a
Merge branch 'master' into docs2
jdconrad May 22, 2018
7b70e15
Start of structural change for operators.
jdconrad May 22, 2018
093a10f
Moved operations to the appropriate pages.
jdconrad May 23, 2018
bb4dc1c
More clean up.
jdconrad May 23, 2018
8f9b09e
Merge branch 'master' into docs5
jdconrad May 24, 2018
a122212
Added a casting table.
jdconrad May 24, 2018
2665835
Switch assign/access to store/load in examples.
jdconrad May 24, 2018
aeb879b
Cleaned up some of the general operators.
jdconrad May 24, 2018
7165b0f
Merge branch 'master' into docs5
jdconrad May 29, 2018
ba4b7c1
Merge branch 'master' into docs5
jdconrad May 30, 2018
b0c2512
Merge branch 'master' into docs5
jdconrad May 31, 2018
b1d31d1
Clean up of general operators.
jdconrad May 31, 2018
246c824
Fix examples with load from instead of load.
jdconrad May 31, 2018
4e2b89d
Update structure for long-term spec goals.
jdconrad May 31, 2018
8b5316b
Merge branch 'master' into docs5
jdconrad May 31, 2018
8302de3
Clean up numerical operators.
jdconrad Jun 1, 2018
7ad8379
Merge branch 'master' into docs5
jdconrad Jun 1, 2018
1d64edd
Merge branch 'docs5' into docs6
jdconrad Jun 1, 2018
0696c83
Partially completed clean up of reference type operators.
jdconrad Jun 1, 2018
46a868e
Completion of clean up of reference type operators.
jdconrad Jun 2, 2018
15aac91
Clean up of array operators section.
jdconrad Jun 2, 2018
f85e235
Partially completed boolean operators clean up.
jdconrad Jun 2, 2018
6f16058
More clean up.
jdconrad Jun 2, 2018
775cfff
More clean up.
jdconrad Jun 2, 2018
610d67c
Completion of operators clean up.
jdconrad Jun 2, 2018
3b8da65
Fix Java to Painless.
jdconrad Jun 2, 2018
33b7357
Merge branch 'master' into docs5
jdconrad Jun 2, 2018
d17c365
Merge branch 'master' into docs5
jdconrad Jun 3, 2018
a2afc62
Merge branch 'docs5' into docs6
jdconrad Jun 3, 2018
8c87bf9
Merge branch 'docs6' into docs7
jdconrad Jun 3, 2018
5b19038
Merge branch 'docs7' into docs8
jdconrad Jun 3, 2018
46f737f
Merge branch 'docs8' into docs9
jdconrad Jun 3, 2018
9439b92
Fix missing lang.
jdconrad Jun 3, 2018
5aaa88a
Merge branch 'docs5' into docs6
jdconrad Jun 3, 2018
86591c3
Merge branch 'docs6' into docs7
jdconrad Jun 3, 2018
d54e4a0
Fix missing lang.
jdconrad Jun 3, 2018
23c2320
Merge branch 'docs7' into docs8
jdconrad Jun 3, 2018
fba0246
Merge branch 'docs8' into docs9
jdconrad Jun 3, 2018
73ff8a2
Fix missing lang.
jdconrad Jun 4, 2018
2b55029
Merge branch 'master' into docs5
jdconrad Jun 4, 2018
bdb8eb1
Merge branch 'docs5' into docs6
jdconrad Jun 4, 2018
4e2994a
Merge branch 'docs6' into docs7
jdconrad Jun 4, 2018
a570d37
Merge branch 'docs7' into docs8
jdconrad Jun 4, 2018
2e38982
Merge branch 'docs8' into docs9
jdconrad Jun 4, 2018
c688199
Response to PR review.
jdconrad Jun 5, 2018
542f52e
Merge branch 'master' into docs5
jdconrad Jun 5, 2018
e0e7dce
Merge branch 'docs5' into docs6
jdconrad Jun 5, 2018
603e5e5
PR response to numeric operators.
jdconrad Jun 5, 2018
afdc961
Merge branch 'docs6' into docs7
jdconrad Jun 5, 2018
12fb54d
Response to PR comments for reference operators.
jdconrad Jun 5, 2018
c83ecaf
Merge branch 'docs7' into docs8
jdconrad Jun 5, 2018
be37bf1
Cleaned up array operators based on PR feedback.
jdconrad Jun 5, 2018
f0bd472
Merge branch 'docs8' into docs9
jdconrad Jun 5, 2018
c35e977
Clean up boolean operators based on PR feedback.
jdconrad Jun 5, 2018
0760a41
Accidentally left in modified test.
jdconrad Jun 5, 2018
c361792
Response to more PR feedback.
jdconrad Jun 7, 2018
038dd80
Merge branch 'master' into docs5
jdconrad Jun 7, 2018
d20d5d8
Merge branch 'master' into docs5
jdconrad Jun 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
226 changes: 147 additions & 79 deletions docs/painless/painless-casting.asciidoc

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/painless/painless-comments.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ anywhere on a line to specify a single-line comment. All characters from the
`//` token to the end of the line are ignored. Use an opening `/*` token and a
closing `*/` token to specify a multi-line comment. Multi-line comments can
start anywhere on a line, and all characters in between the `/*` token and `*/`
token are ignored. Comments can be included anywhere within a script.
token are ignored. A comment is included anywhere within a script.

*Grammar*

[source,ANTLR4]
----
SINGLE_LINE_COMMENT: '//' .*? [\n\r];
Expand Down
24 changes: 24 additions & 0 deletions docs/painless/painless-functions.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[[painless-functions]]
=== Functions

A function is a named piece of code comprised of one-to-many statements to
perform a specific task. A function is called multiple times in a single script
to repeat its specific task. A parameter is a named type value available as a
<<painless-variables, variable>> within the statement(s) of a function. A
function specifies zero-to-many parameters, and when a function is called a
value is specified per parameter. An argument is a value passed into a function
at the point of call. A function specifies a return type value, though if the
type is <<void-type, void>> then no value is returned. Any non-void type return
value is available for use within an <<painless-operators, operation>> or is
discarded otherwise.

You can declare functions at the beginning of a Painless script, for example:

[source,painless]
---------------------------------------------------------
boolean isNegative(def x) { x < 0 }
...
if (isNegative(someVar)) {
...
}
---------------------------------------------------------
81 changes: 0 additions & 81 deletions docs/painless/painless-general-syntax.asciidoc

This file was deleted.

8 changes: 6 additions & 2 deletions docs/painless/painless-identifiers.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

Use an identifier as a named token to specify a
<<painless-variables, variable>>, <<painless-types, type>>,
<<dot-operator, field>>, <<dot-operator, method>>, or function.
<<painless-keywords, Keywords>> cannot be used as identifiers.
<<field-access-operator, field>>, <<method-call-operator, method>>, or
<<painless-functions, function>>.

*Errors*

If a <<painless-keywords, keyword>> is used as an identifier.

*Grammar*
[source,ANTLR4]
Expand Down
10 changes: 7 additions & 3 deletions docs/painless/painless-keywords.asciidoc
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[[painless-keywords]]
=== Keywords

Keywords are reserved tokens for built-in language features and cannot be used
as <<painless-identifiers, identifiers>> within a script. The following are
keywords:
Keywords are reserved tokens for built-in language features.

*Errors*

If a keyword is used as an <<painless-identifiers, identifier>>.

*Keywords*

[cols="^1,^1,^1,^1,^1"]
|====
Expand Down
15 changes: 15 additions & 0 deletions docs/painless/painless-lambdas.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[[painless-lambdas]]
=== Lambdas
Lambda expressions and method references work the same as in https://docs.oracle.com/javase/tutorial/java/javaOO/lambdaexpressions.html[Java].

[source,painless]
---------------------------------------------------------
list.removeIf(item -> item == 2);
list.removeIf((int item) -> item == 2);
list.removeIf((int item) -> { item == 2 });
list.sort((x, y) -> x - y);
list.sort(Integer::compare);
---------------------------------------------------------

You can make method references to functions within the script with `this`,
for example `list.sort(this::mycompare)`.
20 changes: 19 additions & 1 deletion docs/painless/painless-lang-spec.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,22 @@ include::painless-casting.asciidoc[]

include::painless-operators.asciidoc[]

include::painless-general-syntax.asciidoc[]
include::painless-operators-general.asciidoc[]

include::painless-operators-numeric.asciidoc[]

include::painless-operators-boolean.asciidoc[]

include::painless-operators-reference.asciidoc[]

include::painless-operators-array.asciidoc[]

include::painless-statements.asciidoc[]

include::painless-scripts.asciidoc[]

include::painless-functions.asciidoc[]

include::painless-lambdas.asciidoc[]

include::painless-regexes.asciidoc[]
13 changes: 8 additions & 5 deletions docs/painless/painless-literals.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Use a literal to specify a value directly in an
<<painless-operators, operation>>.

[[integers]]
[[integer-literals]]
==== Integers

Use an integer literal to specify an integer type value in decimal, octal, or
Expand All @@ -16,6 +16,7 @@ to specify an integer literal as octal, and use `0x` or `0X` as a prefix to
specify an integer literal as hex.

*Grammar*

[source,ANTLR4]
----
INTEGER: '-'? ( '0' | [1-9] [0-9]* ) [lLfFdD]?;
Expand Down Expand Up @@ -44,7 +45,7 @@ HEX: '-'? '0' [xX] [0-9a-fA-F]+ [lL]?;
<5> `int -18` in octal
<6> `int 3882` in hex

[[floats]]
[[float-literals]]
==== Floats
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beware that changing the anchors affects any cross-refs to these sections.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the head up. I've been pretty good about compiling the docs and looking at the format each time I change something significant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that I'm fairly confident nothing is referring to the headers outside the book since I've added the majority of them recently.


Use a floating point literal to specify a floating point type value of a
Expand All @@ -53,6 +54,7 @@ single letter designations to specify the primitive type: `f` or `F` for `float`
and `d` or `D` for `double`. If not specified, the type defaults to `double`.

*Grammar*

[source,ANTLR4]
----
DECIMAL: '-'? ( '0' | [1-9] [0-9]* ) (DOT [0-9]+)? EXPONENT? [fFdD]?;
Expand All @@ -78,7 +80,7 @@ EXPONENT: ( [eE] [+\-]? [0-9]+ );
<4> `double -126.34`
<5> `float 89.9`

[[strings]]
[[string-literals]]
==== Strings

Use a string literal to specify a <<string-type, `String` type>> value with
Expand All @@ -88,6 +90,7 @@ include a single-quote as part of a single-quoted string literal. Use a `\\`
token to include a backslash as part of any string literal.

*Grammar*

[source,ANTLR4]
----
STRING: ( '"' ( '\\"' | '\\\\' | ~[\\"] )*? '"' )
Expand All @@ -114,9 +117,9 @@ STRING: ( '"' ( '\\"' | '\\\\' | ~[\\"] )*? '"' )
"double-quoted with non-escaped 'single-quotes'"
----

[[characters]]
[[character-literals]]
==== Characters

A character literal cannot be specified directly. Instead, use the
Character literals are not specified directly. Instead, use the
<<string-character-casting, cast operator>> to convert a `String` type value
into a `char` type value.
Loading