Eolas interpreter
Project description
Eolas is a toy language derived from a @Maitre_Eolas’ Tweet. A few people responded to the Tweet saying it was invalid code and it wouldn’t be possible to write such program in any language due to obvious flaws like = for comparison and strings without quotes.
This project provides an interpreter for that language. It parses the original program and evaluates it as intended.
Install
Eolas is distributed as a Python3 library and executable:
pip install eolas
Note: you may need to use pip3 instead of pip if your default installation is Python 2.
Run
Run eolas --help to see all options. The interpreter reads from STDIN unless you give it a filename. You may also evaluate short programs using --eval "<your code>".
You can set the original memory using --set name=value. Compare the results when the interpreter is run on the original program:
$ eolas code.eolas lose $ eolas --set 'avocat=Maitre Eolas' code.eolas Win
Specification
The original code block:
{ IF (avocat = Maitre Eolas) THEN (Result = Win) ELSE (Result = lose) return 0; }
In Eolas, a program is a suite of instructions wrapped in curly brackets.
Instructions
Eolas has three instructions:
IF (condition) THEN (instruction) ELSE (instruction): Usual if/then/else. The ELSE part is mandatory as well as parentheses everywhere. You can’t have more than one instruction in each part. The condition can be any expression.
Assignment: assignments in Eolas work as expected, using the syntax name = value. All variables are global and names may contain spaces.
return code: Interrupt the program with the given exit code.
A program may store its result in a special variable Result. It’ll be printed by the interpreter at the end.
Expressions
Only three value types are supported: integers, strings, and booleans. There is no literal for booleans; they can only be obtained through comparison operators. There’s only one such operator for now: = to check for equality.
The = operator is right-associative, so you can write code like this:
{ this_is_true = 42 = 42 }
Variables may contain spaces and evaluate to their string representation if they’re not set. There is no other way to write strings, and as such empty strings can’t be written.
Negative integers are not supported.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file eolas-0.1.0.tar.gz
.
File metadata
- Download URL: eolas-0.1.0.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5988228bab26ca02feaf40a595b24cc028f3b7efd73ede4951dc9f955ab94ed1 |
|
MD5 | e7f8cffb76f9bbc4b6450a02aecaa200 |
|
BLAKE2b-256 | 78692323c82747a8f1c8a449cd6e9d592986d290be18f6aa1499ef243cc1afab |