be5invis/PatEL is an open-source project on GitHub with 57 stars, written primarily in JavaScript. The Patrisika Example Language
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
PatEL's syntax is based on Lisp's S-expression but with two significant changes:
Supports infix operators, like (1 + 2).
Use indents to avoid too-deep nests.
There are three fundamental constructions in PatEL:
Invocation: [a b c]
Infix: (x + y)
Struct: {a b c} and {.a 1 .b 2}
For invocations you can replace [a b [c d [e f g]]] with [a b : c d : e f g] to eliminate deep nests.
Invocations and Infixes can be written in line-level like this:
f2 a b c : x y z
d e f
g h i
j + k
This is identical to the form [f2 a b c [x y z [d e f] [g h i] (j + k)]], but much clearer.
Primitive Semantics
[if testconsequentalternate]
Evaluate test, then when it is true, evaluate and return consequent, otherwise evaluate and return alternate.
[if testconsequent]
Evaluate test, then when it is true, evaluate and return consequent, otherwise return nothing.
[piecewise [condition1consequent1] [condition2consequent2] ...]
Evaluate condition1, when it is true, evaluate and return consequent1; otherwise, evaluate the rest condition-consequent pairs in the same manner. When all conditions are all false, return nothing.
[match term [pattern1consequent1] [pattern2consequent2] ... ]
Evaluate term, and test whether it matches pattern1. When it matches, extract the parts mentioned in the pattern, evaluate and return consequent1. Otherwise, evaluate the rest pattern-consequent pairs in the same manner. When all patterns mismatch, return nothing.
Sample:
define [sum list] : match list
{} 0 # empty
{head :: rear} : head + [sum rear] # cons
otherwise : throw : new Error "Input is not a list." # everything else
[while testbody]
Assign temporary variable t to nothing.
Evaluate test, then when it is true, evaluate body and set t to the value of body, then loop; otherwise return t.
[return e]
Evaluate e, and immediately return the current function valued e.
[throw e]
Evaluate e, and throw an exception valued e.
[yield e]
Mark the current function as Generator Function.
Evaluate and yield e.
Sample:
define [endless] : begin
local x 0
while true : begin
yield x
set x : x + 1
define g : endless
console.log [g.next].value # 0
console.log [g.next].value # 1
[foreach [erange] body]
Enumerate items in range using standard ES6 semantics, assign the current item to e and evaluate body.
[define evalue]
Define a local constant e and set its value to value.
[local evalue]
Define a local variable e and set its value to value.
[local x]
Declare a local variable x and set it to nothing.
[define [fabc] body]
Define a local constant f, and set it to a function takes parameters a, b and c, and returns body.
[local [fabc] body]
Define a local variable f, and set it to a function takes parameters a, b and c, and returns body.
[define patternvalue]
Assign value to pattern, and declare all variables occurred in pattern as local constant. Function call patterns are not supported here. Function call patterns are not directly supported here, but can be used as sub-pattern.
[local patternvalue]
Assign value to pattern, and declare all variables occurred in pattern as local variable. Function call patterns are not directly supported here, but can be used as sub-pattern.
[lambda [abc] body]
Returns a function which takes parameters a, b and c, and returns body.
[set patternvalue]: Set pattern value to value. Function call patterns are not directly supported here, but can be used as sub-pattern.
[begin ab ... z]: Evaluate a, b, ..., z in order and return z's value.
Yes — be5invis/PatEL ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/be5invis/PatEL.
What is be5invis/PatEL?
be5invis/PatEL (be5invis/PatEL) is a JavaScript project on GitHub. From the project's own README: The Patrisika Example Language
Where do I read more about be5invis/PatEL?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/be5invis/PatEL is the definitive source.
Read full README in the tab above.
Want a second opinion on PatEL?
Ask an AI that can read this page — one click and you get its take on PatEL.