Rivulet

From Esolang
Jump to navigation Jump to search

Rivulet is a programming language of flowing strands, written in semigraphic characters. A strand is not pictographic: its flow does not simulate computation. There are four kinds of strands, each with their own symbolism and grammatical rules. Together, they form glyphs, tightly-packed blocks of code whose strands execute together.

Design Inspiration

Rivulet was influenced by mazes, space-filling algorithms, Anni Albers’s Meander series, and calligraphy-friendly conlangs and natlangs.

Rivulet allows for many ways to write the same code. The parser produces svg images of the source code, with color-coded strands. Here are three inscriptions of the same Fibonacci program. They produce equivalent computer instructions:

   

The top glyph of each produces a list with the numbers 0, 1, and 21. The way they calculate these constants varies in each of these programs.

Lexemes

Rivulet commands are written with these signs. Some re-use characters in a way that only context can disambiguate:

Name Signs Context Interpretation
Glyph Start and End ╵ ╷ Not be adjacent another sign with a vertical reading Marks the glyph, the smallest block of code in Rivulet
Location ╵ ╷ ╴╶ Leaves a gap, to punctuate the end of a strand e.g. from left: ──╶ A reference pointer to a cell
Continue ─ │ Continues the flows in the same direction e.g. ──── Depending on the strand type, it can add or subtract the line number of its horizontal or vertical line number, or simply continue the strand
Corner ╯┘╰└ ╮┐╭┌ Sharp or curved corners have the same meaning and can be used interchangeably Turns direction of flow
Hook ╯┘╰╴└╴ ╮┐╭╴┌╴ It's a character or characters that turn ninety degrees at the beginning of some strands. If it turns to the right or left, it is extended with a half-length line, the same character used to indicate Location, but flipped to extend the hook and not leave a gap.
Non-hook Begin Strand ╷ above a │ Strands with no hook begin with the half-length character to extend it Marks the beginning of a Question Strand

Strand Types

Type Indicates Starts With Ends With How it's read
Value Strand Constant Value Hook facing up or left full-width or -height line Starts with cell to write to. Const written in movement to the right (to add value of its line number), or left (subtracts that value)
Ref Strand A List Element Hook facing up or left Small gap and half-size line Ends on the line of its list, before the starting hook of its cell (if there is one)
Action Strand: Cell Command to execute Hook facing down or right Vertical full-length line Movement down adds to value, up subtracts, then matched to list of commands
Action Strand: List Command to execute Hook facing down or right Horizontal full-length line Movement down adds to value, up subtracts, then matched to list of commands
Question Line (Top) Cell or List to test Vertical half-size line Vertical full-length line Ending to the right (vs its start) indicates repeat on fail, left indicates skip on fail
Question Line (Bottom) Cell or List to test Vertical half-size line Vertical or horizontal full-length line, directly below end of Question Line (Top) Ending on horizontal indicates list, vertical indicates cell

Example

This example is the source for the first of the svg images in Design Inspiration. It calculates Fibonacci numbers up through 21:

  ╵──╮───╮╭─    ╵╵╭────────╮
   ╰─╯╰──╯│       ╰─╶ ╶╮╶╮╶╯
  ╰─────╮ │      ╭─────╯ ╰─────╮
        ╰─╯ ╷    ╰───       ───╯╷
 
  ╵╵─╮  ╭─╮     ╭──       ╵╵╰─╮  ──╮──╮
     ╰─╮│ ╰─╯ ╵╵╰─╯╶╮       ╴─╯  ╭─╯╭─╯
     ╰─╯╰─ ╰──╯╰────╯       ╭╴ ╵╶╯ ╶╯╶╮
       ╭─╮ ╭╴               │  ╰──────╯
       │ │ │                ╰─╮       ╭─╮ 
     │ │ ╰─╯                  │     │   │
     ╰─╯            ╷         ╰──── ╰───╯╷
 
  ╵╵ ╭──  ──╮  ╭─╮         ╵╰─╮
     ╰─╮  ╭─╯╭─╯ │          ╴─╯
      ╶╯╵╶╯  │ ╷╶╯          ╭─╮
    ╭─╮ ╰────╯ │   ╭─╮        │
    │ ╰────╮ ╭─╯ ╭╴│ │      ╭─╯
    ╰────╮ │ │ │ │ │ │      │
    ╭────╯ │ │ ╰─╯ │ ╷      ╰─╷
    ╰────╮ │ ╰─────╯ │  
         │ ╰─────────╯╷

Links