XL (eXtensible Language)

from Wikipedia, the free encyclopedia
XL
Paradigms : multiparadigmatic : concept-oriented , imperative
Publishing year: 2000
Designer: Christophe de Dinechin
Developer: Christophe de Dinechin
Current  version : 0.1   ()
Typing : strong
Influenced by: Ada , C ++
Operating system : Unix-like
License : GPLv2
xlr.sf.net

XL stands for English "eXtensible Language", ie "expandable programming language". XL is a programming language designed to support the conceptual programming paradigm .

XL provides individually reconfigurable syntax and semantics. Compiler plug-ins can be used to add more functionality to the language. A basic set of plug-ins implements a fairly "normal" imperative programming language. Programmers can write their own plug-ins that, for example, provide functions such as the symbolic differentiation of equations. These functions can then be used just like the built-in features.

language

XL is defined or divided on four levels:

  • XL0 defines how an input text is transformed into a syntax tree .
  • XL1 defines a basic language with properties comparable to C ++.
  • XL2 defines the standard library , which includes general data types and operators.
  • XLR defines a dynamic runtime for XL based on XL0.

XL has no elementary data types or keywords. All operators and data types, such as integer numbers or addition , are defined in the standard library (XL2). XL1 is portable between different execution environments. This does not apply to XL2; For example, if a particular CPU does not implement floating point multiplication, the associated operator may be missing in the standard library, and using floating point multiplication in the source code will result in an error during compilation.

The Hello World program looks like this in XL:

 use XL.TEXT_IO
 WriteLn "Hallo Welt"

An alternate form, in a style suitable for large programs, would look like this:

 import IO = XL.TEXT_IO
 IO.WriteLn "Hello World"

A recursive implementation of the faculty would look like this:

 0! -> 1
 N! -> N * (N-1)!

syntax

The syntax of XL is defined in the XL0 level. The XL0 level of the compiler can be configured by a syntax description file in which properties such as the text display or the operator precedence are defined. A basic syntax file also defines general mathematical notations, such as B. '+' for addition .

The syntax tree consists of 7 node types, 4 leaf node types ( integer , real , text and symbol ) and 3 inner node types ( infix , prefix and block )

  • The integer type represents an integer literal such as 2. The #symbol can be used to define a base other than 10, as in 2#101101. A separating underscore can be used to improve readability, e.g. B. 1_000_000.
  • The real type represents non-integer numerical values, such as 2.5. There Basic Information and separators are used as integers so 16#D.6FD#E-10.
  • The text type represents texts or strings . This type is usually enclosed in single or double inverted commas, i.e. "Foo"or 'bar', but the syntax file can also define other separators, including those for multi-line texts.
  • The symbol type represents names or operators. Names are sequences of alphanumeric characters that begin with a letter, such as B. Hello. Symbols are sequences of non-alphanumeric characters such as *or =/=. Symbol is case-sensitive, but XL1 is case-insensitive and underscores, so FooBarand are foo_barconsidered equivalent.
  • infix nodes represent two nodes linked by an insertion, such as A+1or 2 and 3. Infix nodes are used in some cases to separate lines with the addition of “new-line”.
  • prefix nodes represent two consecutive nodes, such as Write "Hello". This type is also used for Postfix notations, such as 3!or Open?.
  • block nodes represent a node enclosed by grouping symbols, such as (A)or [Index]. Indentation is represented internally by a block node.

With the preset syntax file, the following example is a valid XL0, whereby the semantics are unimportant:

A = B + "Hallo"

Becomes:

infix("=",
      symbol("A"),
      infix("+",
            symbol("B"), text("Hallo")))

Semantics of XL1

The XL1 phase is defined as a sequence of operations on the XL0 syntax tree. These operations are made available by various compiler plug-ins that are executed based on the shape of the syntax tree.

Certain constructs, translateand translation, are provided by a plug-in that allows other plug-ins to be written. The quoteconstruct generates a syntax tree. Here's how these notations can be used to implement a plug-in named ZeroRemovalthat eliminates unnecessary additions and multiplications by 0.

  when
    'X' + 0
  then
    return X
  when
    'X' * 0
  then
    return parse_tree(0)

A plug-in can be activated for an entire file, either via the command line, or more locally in the source code, using the pragma notation:

X := {Differentiate} d(sin(omega * T) * exp(-T/T0)) / dT

The XL1 level contains a large set of plug-ins, especially those XLSemanticsthat provide general abstractions such as subroutines , data types and variable declarations and definitions, as well as basic structured statements such as If gates or loops .

Development status and history

The current XL is the result of a long development work that began around 1992. The language was mainly developed and implemented by Christophe de Dinechin.

First of all, the XL compiler was written in C ++. He had reached a point where most of the intended properties were working correctly, but writing plug-ins was very difficult because C ++ itself is not extensible, making translateit impossible to implement -like expressions. The syntax tree was more complicated with dozens of node types because it was designed to support multiple languages ​​at the same time (cross-language support). There is a Java-to-Java compiler called "Moka" that uses the same infrastructure.

In 2003, a completely new compiler was written to exit the complex syntax tree structure. The syntax tree has been greatly simplified, down to the 7 XL0 node types that are now in use. With this new compiler, bootstrapping started in 2004, and all current development of developer tools is done in XL. Nevertheless, the compiler still has partially incompatible XL1 support, although its capabilities already surpass C ++ in some areas.

ancestry

XL1 is influenced by a large number of other languages:

  • Ada influenced exception handling, task management, maintenance aspects and parts of the infrastructure for modularizing larger programs.
  • BASIC , especially the modern versions that do without line numbers and support structured programming, as well as show how simple a programming language can be.
  • C was used as a measure of runtime and machine level support. XL does not require a virtual machine to run.
  • C ++ and the Standard Template Library demonstrated the need for good support for generic types, including implicit instantiation (which Ada lacks).
  • Fortran's unbroken performance lead over C and C ++ in numerically intensive applications helped to find out which language constructs would prevent useful optimizations.
  • Java demonstrated the importance of a large, portable support library. The Java containers also showed the limits of a non-generic programming approach. Coupling with Java code remains an interesting challenge for XL.
  • Lisp's extensibility was seen as a key factor in relevance and survival to this day. LISP was the first language to standardize object-oriented features, although it was developed years before the idea of ​​object-orientation emerged.
  • Prolog showed that alternative programming models are sometimes useful and highly productive. A lot of effort has been made to ensure that XL plug-ins like Prolog are possible.
  • Visual Basic showed how the syntax tree can be separated from the visual representation. Few people edit VB forms as text. It is expected that XL's editing plugins will one day also provide similar capabilities for editing the syntax tree immediately.

Semantics of XLR

XLR is a dynamic language that was originally planned as the backend for the XL1 compiler, but is now the name for the XL runtime. XLR uses the basic syntax of XL0 together with XL1, but the behavior can be classified much closer to a functional language, whereas XL1 was designed as a more imperative-looking language. XLR practically only has one built-in operator, " ->", which marks a rewrite. The spelling on the left side of the operator is converted to the notation on the right side.

This mechanism is used to implement standard notation:

 if true then TrueBody else FalseBody -> TrueBody
 if false then TrueBody else FalseBody -> FalseBody

Web links

Individual evidence

  1. ^ Phil Manchester: "Dip into Concept Programming" , The Register. Retrieved February 3, 2010.