phorward / xpl

An eXample Programming Language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

  • C-like language syntax
  • Arithmetic and conditional expressions
  • Dynamically typed
  • 3 data-types: integer, float, string
  • Simple control structures (conditionals, iterations)
  • 6 build-in functions for simple data manipulation routines and input/output facilities: exit(), print(), prompt(), integer(), float(), string()

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.

About

An eXample Programming Language

License:Other


Languages

Language:C 95.1%Language:XProc 2.7%Language:Makefile 2.2%