Semeler

From Esolang
Jump to navigation Jump to search

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:

  1. Let step be a step.
  2. If step has substeps,
    1. If step has a substep than ran and evaluated to something
      1. Return the last such substep
    2. Else
      1. This step doesn't evaluate to anything
  3. If that step returns or outputs or errors or logs something, return something
  4. 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:

  1. Let index be 0
  2. For every entry in the following table (in order from top to bottom)...
    1. Let tokenRegex be the regex in cell 1 of that entry
    2. If sourceCode.slice(index) matches the tokenRegex
      1. Let tokenMatch be that match
      2. Run the Function in cell 2
      3. Unless otherwise specified by the Function in cell 2...
        1. Set index to index + tokenMatch.length
        2. If index is sourceCode.length
          1. Output the result of step 2.2.2
        3. Else
          1. Run step 2 again
  3. Increment index
  4. If index is not sourceCode.length
    1. Go to step 2

The token table

The token table
Regex Function
* Output the result of the last expression