Node:X Language classes, Next:, Previous:Directory structure, Up:Top

3 X Language Classes

3.1 Expressions

The most important class in X Language is probably XLExpr. Nearly everything in X Language is based on XLExpr. An expression can be of different type :

e.g. "string", 1.23, 234, true, ...
e.g. string, uint, MyClass, ...
e.g. my_identifier; it could be a variable, a function or a class name
e.g. +, -, fnct, class, my_fnct, ...

Moreover, an expression has a list of sub-expressions. This feature is only usefull to function expression (it serves as parameters). All expressions can be evaluated. For functions, that means calling the associated function. The result of this is a value : expr->ret_data.

NOTE: Nothing new here for a real programming language developer.

3.2 Functions

There is three type of function :

3.2.1 Built-in

Built-in functions are registered in xlbuiltin.c. Here is the prototype of a built-in function :

void builtin_fnct (XLExpr* expr);

Examples of built-in functions are (+, -, *, /, class, fnct, ...). Those functions provides low-level access to the X Language environment. With them, we can create functions 'fnct', classes 'class', variables 'local & global', flow control 'if, while, ...'. Parsers uses those functions to create an expression-tree.

New built-in functions will be created to accomodate new concepts (beyound OO).

3.2.2 Native functions

Native functions are a little more complicated. They are there to map 'C' functions. Using a special technic, X Language know how to push parameters from XLExpr to the native 'C' function pointer. It's a little hard to explain. I suggest you to read 'xlfnct.c' source file.

3.2.3 User's function

A user's function is a function as described by the 'fnct' built-in function. It's nothing more than a pointer to the XLExpr to be evaluated when a call is made. Parameters are transformed as local variable using parameter's description of the user's function.