[[painless-lang-spec]]
== Painless Language Specification

Painless is a scripting language designed for security and performance.
Painless syntax is similar to Java syntax along with some additional
features such as dynamic typing, Map and List accessor shortcuts, and array
initializers. As a direct comparison to Java, there are some important
differences, especially related to the casting model. For more detailed
conceptual information about the basic constructs that Painless and Java share,
refer to the corresponding topics in the
https://docs.oracle.com/javase/specs/jls/se8/html/index.html[Java Language
Specification].

Painless scripts are parsed and compiled using the http://www.antlr.org/[ANTLR4]
and http://asm.ow2.org/[ASM] libraries. Scripts are compiled directly
into Java Virtual Machine (JVM) byte code and executed against a standard JVM.
This specification uses ANTLR4 grammar notation to describe the allowed syntax.
However, the actual Painless grammar is more compact than what is shown here.

include::painless-comments.asciidoc[]

include::painless-keywords.asciidoc[]

include::painless-literals.asciidoc[]

include::painless-identifiers.asciidoc[]

include::painless-variables.asciidoc[]

include::painless-types.asciidoc[]

include::painless-casting.asciidoc[]

include::painless-operators.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[]
