Next: 4.2 Coercion Up: 4 The Language Previous: 4 The Language

4.1 Lexical Conventions

Lua is a case sensitive language. Identifiers can be any string of letters, digits, and underscores, not beginning with a digit. The following words are reserved, and cannot be used as identifiers:

         and      do        else      elseif    end
         function if        local     nil       not
         or       repeat    return    until     then    while

The following strings denote other tokens:

         ~=  <=  >=  <   >   ==  =   ..  +   -   *   /
         %   (   )   {   }   [   ]   ;   ,   .

Literal strings can be delimited by matching single or double quotes, and can contain the C-like escape sequences '\n', '\t' and '\r'. Literal strings can also be delimited by matching [[ ... ]]. Literals in this last form may run for several lines, may contain nested [[ ... ]], and do not interpret escape sequences.

Comments start anywhere outside a string with a double hyphen (--) and run until the end of the line.

Numerical constants may be written with an optional decimal part, and an optional decimal exponent. Examples of valid numerical constants are:

       4     4.     .4     4.57e-3     .3e12


Next: 4.2 Coercion Up: 4 The Language Previous: 4 The Language