Simple expressions are:

Numbers (numerical constants) and string literals are explained in Section 4.1. Variables are explained in Section 4.4.2.exp::= '('exp')'

exp::=nil

exp::= 'number'

exp::= 'literal'

exp::=var

Lua supports the usual arithmetic operators.
These operators are the binary
`+`,

Lua offers the following relational operators:

All return< > <= >= ~= ==

Equality first compares the types of its operands.
If they are different, the result is **nil**.
Otherwise, their values are compared.
Numbers and strings are compared in the usual way.
Tables, CFunctions, and functions are compared by reference,
that is, two tables are considered equal only if they are the same table.
The operator `~=` is exactly the negation of equality (

The other operators work as follows. If both arguments are numbers, they are compared as such. Otherwise, if both arguments can be converted to strings, their values are compared using lexicographical order. Otherwise, the fallback ``order'' is called; see Section 4.7.

All logical operators, like control structures,
consider **nil** as false and anything else as true.
Like relational operators,
they return **nil** as false and 1 as true.
The logical operators are:

The operatorsand or not

Lua offers a string concatenation operator, denoted by ```..`''.
If operands are strings or numbers, they are converted to
strings according to the rules in Section 4.2.
Otherwise, the fallback ``concat'' is called; see Section 4.7.

Operator precedence follows the table below, from the lower to the
higher priority:

All binary operators are left associative, except forand or < > <= >= ~= = .. + - * / not - (unary) ^

The general syntax for constructors is:

tableconstructor::= '{' [fieldlist] '}'

fieldlist::=lfieldlist1[ ',' ]

fieldlist::=ffieldlist1[ ',' ]

fieldlist::=lfieldlist1';'ffieldlist1[ ',' ]

The form *lfieldlist1* is used to initialize lists.

The expressions in the list are assigned to consecutive numerical indexes, starting with 1. As an example:lfieldlist1::=exp{ ','exp}

a = {"v1", "v2", 34}

temp = {} temp[1] = "v1" temp[2] = "v2" temp[3] = 34 a = temp

The next form initializes named fields in a table.

As an example:ffieldlist1::=ffield{ ','ffield}

ffield::=name'='exp

a = {x = 1, y = 3}

temp = {} temp.x = 1 temp.y = 3 a = temp

Here,functioncall::=var realParams

The form:

can be used to call ``methods''. A callfunctioncall::=var':'name realParams

var.name(var, ...)

All argument expressions are evaluated before the call; then the list of arguments is adjusted to the length of the list of parameters (see Section 4.3); finally, this list is assigned to the formal parameters. A call of the formrealParams::= '(' [explist1] ')'

realParams::=tableconstructor

explist1::=exp1{ ','exp1}

Because a function can return any number of results
(see Section 4.4.3),
the number of results must be adjusted before used.
If the function is called as an statement (see Section 4.4.4),
its return list is adjusted to 0.
If the function is called in a place that needs a single value
(syntactically denoted by the non-terminal `exp1`),
its return list is adjusted to 1.
If the function is called in a place that can hold many values
(syntactically denoted by the non-terminal

** Next:** 4.6 Function Definitions
**Up:** 4 The Language
** Previous:** 4.4 Statements