Table of Contents

Copying

Introduction

This document provides insides for X Language developers. Please, read this before hacking.

What is X Language ?

X Language is a new multi-syntax programming language wich will ease the creation of big applications. By providing a portable set of APIs, you will be able to create CLI or GUI applications runnable on UNIX/X11 and Win32. X Language come with an interpreter/compiler/debugger. For now, only the interpreter works.

Directory structure

The X Language package comes with many files and directories. Here is the description of the structure used :

/
root directory
/doc/
X Language documentation
/src/
Sources
/test/
Test bench

Next sections contains details informations about each sub-directories.

/ directory

The root directory contains many files usefull to developers.

README
Overview of X Language
TODO
What should be done
INSTALL
How to install X Language
ROADMAP
Development planification
AUTHORS
Contributors to X Language
NEWS
What's new in major releases
ChangeLog
Changes on day basis
xlang-test
A script to automate tests

/doc/ directory

The documentation directory contains developer's and user's informations. Texinfo is used to create those documents. Those guides are also generally available via HTML or PDF.

xlang-develop.texi
X Language Developer's guide
xlang-user.texi
X Language User's guide

/src/ directory

The source files directory contains all (.c & .h) C language files. Since X Language is a medium-size project, those files are divided into sub-directories :

/src/xlib/
Basic utilities (XString, XList, ...)
/src/xapi/
APIs source files
/src/xlang/
Core of the X Language

/src/xlib/ directory

This directory contains basic files for X Language C development :

xdefs.h
Contains all usefull definition (xbool, xu32, ...)
xmem.c/.h
Module to manage memory stuff
xdynamic.c/.h
Module to connect to dynamic libraries
xobject.c/.h
Basic class (the mother of all classes)
xstring.c/.h
Class to manage strings
xlist.c/.h
Class to manage lists

/src/xapi/ directory

This directory contains source files to APIs packages :

lang.c/.h
LANG package (e.g. itostr, ...)
sys.c/.h
SYS package (e.g. sys_exit, ...)
io.c/.h
IO package
net.c/.h
NET package
wnd/*.*
WND package (it's a direct binding of GTK+)

/src/xlang/ directory

This directory contains the core X Language source files :

xlmain.c/.h
This class contains a X Language environment
xlexpr.c/.h
This class describe an expression (fnct, type, variable, ...)
xldata.c/.h
This class describes the internal data at memory level
xltype.c/.h
This class describes a specific type (native or class)
xlfnct.c/.h
This class describe an X Langauge function
xlclass.c/.h
This class contains the description of X Language classes
xlfield.c/.h
This class describe a field of a class
xlvar.c/.h
This class contains the description of X Language variables
xlbuiltin.c/.h
This module contains all built-in functions (e.g. +, -, *, =, ...)
xlapi.c/.h
This module registers all APIs
xllang.c/.h
This class contains tools usefull to parsers and a parser chooser
xllangc.c/.h/.l/.y
C-like language (lexical analyzer & parser)
xllangbasic.c/.h/.l/.y
Basic-like language (lexical analyzer & parser)
xllanglisp.c/.h/.l./.y
LISP-like language (lexical analyzer & parser)

/test/ directory

This directory contains all tests that must be passed prior to any releases. Tests are composed of two files : test-XX.xc (the X Language source file) and test-XX.tst (the output that must be generated). By comparing the real output to the attended output, we know if the test passed.

X Language Classes

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 :

Value
e.g. "string", 1.23, 234, true, ...
Type
e.g. string, uint, MyClass, ...
Identifier
e.g. my_identifier; it could be a variable, a function or a class name
Function
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.

Functions

There is three type of function :

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).

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.

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.