Node:Introduction, Previous:Top, Up:Top



1 Introduction

This document contains the specification of the X Language developers.

1.1 What is X Language ?

This document describes the X Language program, a new multi-syntax programming including a portable set of APIs to create console or graphical applications runnable on many platforms (UNIX/X11, Win32, ...). X Language comes with an interpreter, a compiler and a debugger.

1.2 Copying

Copyright © 2001 Patrick Deschenes

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by Patrick Deschenes.

2 Usage

2.1 General

Usage

xlang [OPTIONS]... [FILES]...

2.2 Options

Short option Long option Description
-h -help Print help and exit
-V -version Print version and exit
-j -jit Turn ON the JIT compiler
-d -debug Turn ON the debugger
-p
-build-package
Build a package

3 C-like Language

3.1 Introduction

C-like language is a language similar to C used in the X Language development framework. There is some big difference with ANSI C like memory and array management but the syntax is similar enough to be learned in a couple of minutes by a C programmer. This chapter describes the C-like language specifications.

3.2 Tutorial

3.2.1 Hello the world


void main (string args[])
{
   io_write ("Hello the world\n");
}

3.3 Basic elements

3.3.1 Types

Basic type Description Example
void Nothing .
bool Boolean type (32-bits) true, false
pointer Pointer type (32-bits) null
char 8-bits signed integer -128, 127
uchar 8-bits unsigned integer 0, 255
short 16-bits signed integer -32767, 32768
ushort 16-bits unsigned integer 0, 65535
int 32-bits signed integer -2147483647, 2147483648
uint 32-bits unsigned integer 0, 4294967294
float 32-bits floating point number -10.5, 10.5
double 64-bits floating point number -10.5, 10.5
string Text string "text\n"

3.3.2 Classes & objects

3.3.3 Arrays

3.4 Lexical analysis

3.4.1 Comments

Syntax

line-terminator:
	CR
	LF

input-character:
	Anything but CR or  LF

input-characters:
	input-character
	input-characters input-character

any-character:
	Anything

any-characters:
	any-character
	any-characters any-character

comment:
	comment-classic
	comment-endline

comment-classic:
	/* any-characters */

comment-endline:
	// input-characters line-terminator

Examples

// Comments until the carriage return

/* Any characters until
    the next
*/

3.4.2 Identifiers

The general syntax of an identifier is the following :

Syntax

letter:
	A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
	a b c d e f g h i j k l m n o p q r s t u v w x y z

digit:
	0 1 2 3 4 5 6 7 8 9

first-character:
	letter
	_
	:

identifier-character:
	letter
	digit
	_
	:

identifier-characters:
	identifier-character
	identifier-characters identifier-character

identifier:
	first-character identifier-charactersopt

Examples

myfnct
myfnct2
_myfnct
my::fnct

3.4.3 Keywords

bool char class const
double else false float
for if import inherit
int new null pointer
return short static string
true uchar uint ushort
void while

3.4.4 Literals

3.4.4.1 Boolean literal

Syntax

bool-literal:
	true
	false

Examples

true
false
3.4.4.2 Integer literal

Syntax

digit: one of
	0 1 2 3 4 5 6 7 8 9

digits:
	digit
	digits digit

integer-literal:
	digits

Examples

0
100
234
3.4.4.3 Floating-point literal

Syntax

float-literal:
	digits . digits

Examples

0.5
1.5
1000.25
3.4.4.4 Character literal

Syntax

character:
	single-character
	escape-character

characters:
	character
	characters character

single-character:
	anything except ' and \

escape-character:
	\r
	\n
	\t
	\"

character-literal:
	' character '

Examples

'A'
'\n'
'x'
'0'
3.4.4.5 String literal

Syntax

string-literal:
	" characters "

Examples

"Hello"
"Hello the world\n"
"\tChapter\n"
3.4.4.6 Object literal

Syntax

null-literal:
	null

Examples

null

3.4.5 Operators & symbols

[ ] ( ) < >
<= >= != ==
! & | ~
&& || << >>
, . ; +
- * / %
^ ++ - +=
-= *= /= %=
<<= >>= &= |=
^=

3.5 Grammar analysis

3.5.1 Introduction

3.5.2 Declarations

3.5.2.1 Variable
3.5.2.2 Function
3.5.2.3 Class

3.5.3 Statement

3.5.3.1 Block
3.5.3.2 Declaration
3.5.3.3 Flow control

3.5.4 Expression

3.5.4.1 Expression
3.5.4.2 Logical
3.5.4.3 Conditionnal
3.5.4.4 Binary
3.5.4.5 Constant
3.5.4.6 Member access
3.5.4.7 Array