Course Lua reference manual programming language

Extrait du course Lua reference manual programming language

1 Introduction
Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++).
2 The Language
This section describes the lexis, the syntax, and the semantics of Lua. In other words, this section describes which tokens are valid, how they can be combined, and what their combinations mean.The language constructs will be explained using the usual extended BNF, in which { a } means 0 or more a ’s, and [ a ] means an optional a. Non-terminals are shown in italics, keywords are shown in bold, and other terminal symbols are shown in typewriter font, enclosed in single quotes.
2.1 Lexical Conventions
Identifiers in Lua can be any string of letters, digits, and underscores, not beginning with a digit.This coincides with the definition of identifiers in most languages. (The definition of letter depends on the current locale: any character considered alphabetic by the current locale can be used in an identifier.)
2.2 Values and Types
Lua is a dynamically typed language. That means that variables do not have types; only values do.There are no type definitions in the language. All values carry their own type.There are eight basic types in Lua: nil , boolean , number , string , function , userdata , thread ,and table . Nil is the type of the value nil, whose main property is to be different from any othervalue; usually it represents the absence of a useful value. Boolean is the type of the values false and true. In Lua, both nil and false make a condition false; any other value makes it true. Number represents real (double precision floating-point) numbers. (It is easy to build Lua interpreters that use other internal representations for numbers, such as single precision float or long integers.) String represents arrays of characters. Lua is 8-bit clean: Strings may contain any 8-bit character, including embedded zeros (’’) (see §2.1).
2.2.1 Coercion
Lua provides automatic conversion between string and number values at run time. Any arithmetic operation applied to a string tries to convert that string to a number, following the usual rules.
Conversely, whenever a number is used where a string is expected, the number is converted to a string, in a reasonable format. For complete control of how numbers are converted to strings, use the format function from the string library (see §5.3).
2.3 Variables
Variables are places that store values. There are three kinds of variables in Lua: global variables,local variables, and table fields.
A single name can denote a global variable or a local variable (or a formal parameter of a function, which is a particular form of local variable):
var → Name


Si le lien ne fonctionne pas correctement, veuillez nous contacter (mentionner le lien dans votre message)
Course Lua reference manual programming language (644 KO) (Cours PDF)
Course Lua Reference

Télécharger aussi :

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée. Les champs obligatoires sont indiqués avec *