Semeler
Semeler is a bunch of languages randomly mashed together. The goal is to make it possible for almost every program to run in Semeler, so that people can code in whatever format they'd like!
Intro continued
This language is described by a few algorithms.
If a feature is used in an algorithm it exists! So if someone put "pop the last element of a string" or even string.slice(84)
as an algorithm step then bam, the functionality exists!
More very loose features
Every Function implicitly evaluates to (the result of the last step).
Which is similar to what Rust does...
fn add(a, b) { a + b }
...here the function implicitly returns a + b
Steps are evaluated like this:
- Let step be a step.
- If step has substeps,
- If step has a substep than ran and evaluated to something
- Return the last such substep
- Else
- This step doesn't evaluate to anything
- If step has a substep than ran and evaluated to something
- If that step returns or outputs or errors or logs something, return something
- If that step is an expression, return the result of evaluating expression
Some example expressions are variable declarations, variable assignments, mathematical expressions, and function calls.
If a step is a variable declaration or assignment, it's returns variable
Main
When running source code, the following function is run:
- Let index be 0
- For every entry in the following table (in order from top to bottom)...
- Let tokenRegex be the regex in cell 1 of that entry
- If sourceCode.slice(index) matches the tokenRegex
- Let tokenMatch be that match
- Run the Function in cell 2
- Unless otherwise specified by the Function in cell 2...
- Set index to index + tokenMatch.length
- If index is sourceCode.length
- Output the result of step 2.2.2
- Else
- Run step 2 again
- Increment index
- If index is not sourceCode.length
- Go to step 2
The token table
Regex | Function |
---|---|
* |
Output the result of the last expression |