XP-Compiler

XP-Language is a feature-rich, typed and compiled programming language, based on the popular PHP language and designed to syntactically support features of the XP Framework

License

License

BSD
Categories

Categories

Net
GroupId

GroupId

net.xp-framework
ArtifactId

ArtifactId

compiler
Last Version

Last Version

5.8.10
Release Date

Release Date

Type

Type

xar
Description

Description

XP-Compiler
XP-Language is a feature-rich, typed and compiled programming language, based on the popular PHP language and designed to syntactically support features of the XP Framework
Project URL

Project URL

https://github.com/xp-framework/xp-language
Project Organization

Project Organization

XP-Framework Team
Source Code Management

Source Code Management

https://github.com/xp-framework/xp-language

Download compiler

Dependencies

compile (2)

Group / Artifact Type Version
net.xp-framework : core Optional xar 5.8.10
net.xp-framework : tools Optional xar 5.8.10

Project Modules

There are no modules declared in this project.

XP Language

Build Status XP Framework Module BSD Licence Required PHP 5.5+ Supports PHP 7.0+ Supports HHVM 3.5+ Latest Stable Version

XP language is a feature-rich, typed and compiled programming language, based on the popular PHP language and designed to syntactically support features of the XP Framework. The source you write and compile with it can make use of the XP Framework's foundation classes. As the language itself is written in the XP Framework, no binary or proprietary extensions are needed!

Getting started

Like in the XP framework, the entry point is always a class. In their most simple form, these classes have a static main() method. To try it out, create a file called HelloWorld.xp with the following contents:

public class HelloWorld {
  public static void main(string[] $args) {
    util.cmd.Console::writeLine('Hello World!');
  }
}

Then compile and run it!

$ xp HelloWorld
Hello World!

Differences

The things you will have noticed are:

  • Classes may also have modifiers.
  • The extends Object is optional and added by the compiler if omitted.
  • The keyword function is gone and replaced by the return type. Because the main() method does not return anything, we use void.
  • An array type is written as component[]
  • Variables still have dollar signs. This makes it easy to spot them, that's why we've decided to keep this!
  • Fully qualified classnames are written with dots.
  • The object operator is also a dot (at the same time, the string concatenation operator is now the tilde, ~).

Features

The XP Language features - among others - support for the following:

  • Namespaces (which are called packages)
  • Imports, static imports and "on-demand" imports (import util.*;)
  • Varargs syntax
  • Distinguishable types for arrays and maps
  • Class literal ::class, and finally - also for PHP < 5.5!
  • Properties with get and set, and Indexers
  • Syntactic support for the following XP Framework features: Typesafe enumerations, Annotations, Generics, the with statement and a throws clause

Further reading

To get an overview of XP Language's features, these are good reads:

Developing

In order to change XP Language and/or the Compiler itself, you need to clone this repository, e.g. using Git Read-Only:

$ cd [path]
$ git clone git://github.com/xp-lang/compiler.git

Directory structure

[path]/compiler
 |- ChangeLog.md      # Version log
 |- README.md         # This file
 |- module.pth        # Module classpath
 `- src               # Sourcecode, by Maven conventions
    |- main
    |  `- php
    `- test
       |- php
       `- config      # Unittest configuration

Using it

Add that path to your use setting before the global module path inside your xp.ini, e.g.:

use=~/devel/xp-framework/core:~/devel/xp-lang/compiler
                              ^^^^^^^^^^^^^^^^^^^^^^^^

On Windows systems, use ; as separator

Enjoy!

Contributing

To contribute, use the GitHub way - fork, hack, and submit a pull request!

net.xp-framework

XP-Framework

Versions

Version
5.8.10
5.8.9
5.8.8
5.8.7
5.8.6
5.8.5
5.8.4
5.8.3
5.8.2