Declarations and Types

This section describes the declaration and initialization of variables. The CLight language includes basic data types.

The declaration of a simple variable specifies the variable's name and type.

Syntax

declaration:  type-specifier identifier ;

Type Specifiers

Type specifiers in declarations define the type of a variable or function declaration.

Syntax

type-specifier:  voidintlong float

The keyword void has two uses: to specify a function return type and to specify an argument-type list for a function that takes no arguments. You can use the void type to declare functions that return no value.

Identifiers

An identifier represents a variable's name.

Syntax

identifier:  [a-zA-Z_][a-zA-Z0-9_]*

Example

int a;
long b;
int abc_8;

Number

The int, long and float types are all a number.

Syntax

number:  [+|-]?[0-9]+ [+|-]?[0-9]+.[0-9]+

Example

170282
0
-142
+33 
0.9
-8.709

Last updated