https://github.com/phorward/xpl
An eXample Programming Language
https://github.com/phorward/xpl
c-like compiler embeddable language programming-language scripting-language toy-language
Last synced: 5 months ago
JSON representation
An eXample Programming Language
- Host: GitHub
- URL: https://github.com/phorward/xpl
- Owner: phorward
- License: other
- Created: 2017-05-26T11:20:59.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-12-20T14:19:17.000Z (almost 7 years ago)
- Last Synced: 2025-06-21T00:52:37.063Z (5 months ago)
- Topics: c-like, compiler, embeddable, language, programming-language, scripting-language, toy-language
- Language: C
- Homepage:
- Size: 17.6 KB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-programming-languages - xpl - eXample Programming Language. 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 (Uncategorized / Uncategorized)
README
# xpl
**xpl**: *eXample Programming Language*.
## About
**xpl** is a tiny toy programming language that is implemented in the course of the [UniCC Parser Generator](https://github.com/phorward/unicc)'s User Manual.
Please check out the [User's Manual](http://phorward.info/download/unicc/unicc.pdf) for implementation details.
## Features
- C-like language [syntax](https://github.com/phorward/xpl/blob/master/xpl.par)
- 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.
```c
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
```bash
./xpl 99bottles.xpl
```
## Credits
*xpl* is developed and maintained by [Jan Max Meyer](https://github.com/phorward/), Phorward Software Technologies.
## License
xpl is under the WTFPL.