Content deleted Content added
Category:Programming languages |
m AWB assisted change "an" to "a". |
||
Line 4:
== Language ==
XL is defined at three different levels:
* XL0 defines how an input text is transformed into a [[parse tree]].
Line 18 ⟶ 17:
== Syntax ==
Syntax is defined at the XL0 level. The XL0 phase of the compiler can be configured using a syntax description file, where properties like the text representation and precedence of operators are defined. A basic syntax file defines common mathematical notations, like + for addition, with the usually accepted [[order of operations]].
Line 41 ⟶ 39:
infix("+",
symbol("B"), text("Hello")))
== Semantics ==
The XL1 phase is defined as a sequence of operations on the XL0 parse tree. These operations are provided by various compiler plug-ins, that are triggered based on the shape of the parse tree.
Line 66 ⟶ 62:
=== Type System ===
XL1 type checking is [[data type|static]], with [[generic programming]] capabilities that are beyond those of languages like C++ or Ada. Types like arrays or pointers, which are primitive in languages like C++, are declared in the library in XL. For instance,
▲XL1 type checking is [[data type|static]], with [[generic programming]] capabilities that are beyond those of languages like C++ or Ada. Types like arrays or pointers, which are primitive in languages like C++, are declared in the library in XL. For instance, an one-dimensional array type could be defined as follows:
generic [DataItem : type; Size : integer] type array
Line 90 ⟶ 85:
for I in 0..array.Size loop
result += A[I]
=== Type-safe variable argument lists ===
Functions can be [[polymorphism|overloaded]]. A function can be declared to use a variable number of arguments by using <code>other</code> in the parameter list. In such a function, <code>other</code> can be used to pass the variable number of arguments to another subroutine:
Line 107 ⟶ 100:
X : real := Min(1.3, 2.56, 7.21)
Y : integer := Min(1, 3, 6, 7, 1, 2)
=== Expression reduction (Operator overloading) ===
Operators can be defined using the <code>written</code> form of function declarations. Below is the code that would declare the addition of integers:
Line 128 ⟶ 119:
== Development status and history ==
Historically, the XL compiler was written in C++. It had achieved a point where most of the features described above worked correctly, but writing plug-ins was a nightmare, because C++ itself is not extensible, so implementing <code>translate</code>-like statements was impossible. The parse tree was more complicated, with dozens of node types, because it was designed for cross-language support. Moka was a Java-to-Java extensible compiler using the same infrastructure.
Line 134 ⟶ 124:
=== Ancestry ===
XL was inspired by a large number of other languages. In alphabetical order:
* [[
* [[Basic programming language|Basic]], notably in the more modern variants that dispense of line numbers and support structured programming, showed how simple the syntax of a programming language could be. For instance, Basic remains one of the only modern languages to not mandate parentheses around subroutine calls.
* [[
* [[C++]] and the [[Standard template library]] demonstrated the need for good support of generic types, including implicit instantiation of generics (which Ada lacks).
* [[Fortran]]'s continued performance lead over C and C++ for numerical-intensive applications helped identify which language constructs would prevent useful optimizations.
* [[Java programming language|Java]] demonstrated the importance of a large, portable support library. Java containers also showed the limitations of an approach not based on generic programming. Interfacing with Java code remains an interesting challenge for XL.
* [[
* [[Prolog]] demonstrated that alternative programming models are sometimes useful and highly productive. Every effort was made to ensure that a Prolog-style plug-in could be written for XL.
* [[Visual Basic]] showed how the parse tree representation can be dissociated from its visual presentation. Few people edit VB Forms textually. It is expected that XL edit-time plug-ins will one day provide similar capabilities, by directly manipulating the parse tree.
|