Home

Awesome

xpl

xpl: eXample Programming Language.

About

xpl is a tiny toy programming language that is implemented in the course of the UniCC Parser Generator's User Manual. Please check out the User's Manual for implementation details.

Features

Building

To build xpl, you need UniCC and any C-compiler. The provided Makefile should do all the rest for you, when unicc is in the PATH.

Example

The "99 bottles of beer" program implemented in xpl.

if( ( bottles = prompt( "Enter number of bottles [default=99]" ) ) == "" )
    bottles = 99;

if( integer( bottles ) <= 0 )
{
    print( "Sorry, but the input '" + bottles + "' is invalid." );
    exit( 1 );
}

while( bottles > 0 )
{
    if( bottles > 1 )
        print( bottles + " bottles of beer on the wall, " +
                bottles + " bottles of beer." );
    else
        print( "One bottle of beer on the wall, one bottle of beer." );

    print( "Take one down, pass it around." );

    if( ( bottles = bottles - 1 ) == 0 )
        print( "No more bottles of beer on the wall." );
    else if( bottles == 1 )
        print( "One more bottle of beer on the wall." );
    else
        print( bottles + " more bottles of beer on the wall." );
}

Run it after building with

./xpl 99bottles.xpl

Credits

xpl is developed and maintained by Jan Max Meyer, Phorward Software Technologies.

License

xpl is under the WTFPL.