pcosmos.ca

le domaine de Philippe Choquette

Accueil Profil Contact Arrière plan
PCASTL
Half-Life
Informatique
OpenGL
Linux
Grow
Elements
Lecture
Liens

PCASTL
by Parent and Childset Accessible Syntax Tree Language

Page en français

The PCASTL is an interpreted high level programming language which makes writing self-modifying code easier. It has three features to reach this goal.

  • The "parent" keyword to access a parent node in the code syntax tree.
  • The "childset" keyword to access a child node in the code syntax tree.
  • The use of explicit code segments delimited with ` and '.

The PCASTL aims use in artificial intelligence. The new technic PCASTL permits is named Dynamic Syntax Tree Edition.

The most recent version is 1.9 and was released on 2009-09-18.

Operators
Data Types
Internal Functions
Tree Structure
Batch Execution
Examples
Interpreter

Basic Examples

The following session example demonstrates the use of the keywords and the use of the info internal function which gives the type of the node reference it receives as argument and some valuable information about the node. PCASTL statements are after the '>' symbols and interpreter output is the text on the lines beginning with spaces.

> a = parent
        0x330878
> info(a)
        Node type: mathematical operator
        Number of childs: 2
        Operator: =
> info(a.childset[0])
        Node type: variable
        Name: "a"
> info(a.childset[1])
        Node type: list
        Number of items: 1
> info(a.childset[1].childset[0])
        Node type: "parent" reserved word
> a.childset[0].parent
        0x330878
> a.childset[1].parent
        0x330878

After the assignation of a value to a variable, the interpreter returns the value. The address we see (0x330878) is in this case the address of the node containing the operator. We also get an address when we define a function and when we declare an explicit code segment. The code we just used is illustrated in the image below.

Simple Tree

A genealogical dotted list is a list of "parent" and "childset" reserved words separated by dots. The "parent" reserved word alone is a genealogical dotted list of one item.

The following session example uses a genealogical dotted list of two items.

> a = parent.childset[1]
        0x330838
> info(a)
        Node type: list
        Number of items: 2
> info(a.childset[1])
        Node type: "childset" reserved word
> info(a.childset[1].childset[0])
        Node type: numerical constant
        Value: 1

The structure of the first statement in the previous example is illustrated below.

Bigger Tree