npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fsmlang

v0.7.3

Published

FSML - homoiconic postfix concatenative programming language. JS implementation

Downloads

20

Readme

FSML

Kawaii homoiconic postfix concatenative programming language

FSML is Forth/Factor-like programming language and transpiller for. Now in infancy. Language expected to be mainly procedural with wide functional style support. Intended mainly to static compilation to othes high-level languages. First to JavaScript, then to others on my choose. Then I hope add interpretation abilities for dialog work.

Stack is abstraction of compile time. Compiler [should] produce code with munimal runtime overhead. With no any virtual machine. With no any byte code or threaded code. With no any stack or stack juggling at run time. Look, text 1 2 3 swap drop + compiled to JS code var subex_0 = 1 + 3; You see no any stack or stack manipulation in produced code, no interpretation at run time, hence no overhead.

Language planed to be mainly lightweight, easy and portable frontend for target languages. It's what CoffeeScript for JavaScript.

Currently implemented quotations. Among control statements implemented 'if' and 'while' statement. Othes control statements not implemented yet.

REPL environment currently not provide interpretation abilities, only manual control of step-by-step compilation process. After every enter hint system type stack from left window margin to right from top of stack to bottom separated by separator like ' -> ' or ' | ' or ', ' or so. Arrow show direction to stack bottom. Stack items is expressions (in form of abstract tree inside system) which keep all history of operations on. Stack items is printed as infix expressions of target language.

Features:

  • Stacks and quotations are the same thing. At time '[' occur, current stacks id keep in stacks chain, new empty stack allocated and established as current. At time ']' occur, id of current (nested) quotation/stack placed on top of embrace (previous) stack and previous stack established as current again. For example text 12 34 [ 56 78 ] leave stack Quot -> 34 -> 12, where Quot is pointer to stack/quotation which contain elements 78 -> 56.

  • Operations on empty stack allowed! It produce expressions with variables. Enclose it in brackets produce quotation. Text 1 2 [ [ + ] apply ] apply also work as well as 1 2 [ + ] apply.

  • Objects duplicated with classic Forth words as dup, over, etc accessible by reference not by value! Need 'ind' to detach stack item and some time 'dc' to deep copy of object which stack item refer to. Apply quotation on current stack convert this quotation and current stack to bunch of expressions of current stack which is quotation per se. It is not obligate expressions with variables. Although if arguments of quotation contain variables itself or just not enough arguments for quotation in current stack then 'apply' produce expressions with variables. Need use 'dc' on copy of quotation for keep original quotation for use late. Otherwise any 'apply' occured transform it in itself distinctive manner.

  1. From under the node just run fsml in the shell, if installed globally sudo npm i -g fsmlang. Or run node dist/fsml.js

  2. Run in browser from under the local server with the root in "./simple sample browser console".

Command line starts with '> ' or 'fsml > ' or 'fsml> '. Almost no error handling yet. On error system often crush and require reload of page. Open browsers console to track it.

Example of transpiling to JS with '.js' :

12 34 + 56 78 -

\ [2]  56 - 78 -> 12 + 34

.js

\ var subex_2 = 12 + 34;
\ var subex_3 = 56 - 78;

Example of JS evaluation with '.eval' :

as df + 56 78 -

\ [2]  56 - 78 -> "as" + "df"

.eval

\ evaluated stack: [ -22, asdf ]

Example of limited conversion of expression on top of the stack to an anonymous oneliner procedure with 'ol' :

+ * ol

\ [1]  (var_2, var_3, var_4) => var_4 * (var_3 + var_2)

Example of defining an anonymous procedure and assigning it to the variable 'mul' with '!' :

* ol mul !    .js

\ var mul = (var_0, var_1) => var_1 * var_0;

Example of computing factorial of 12 in functional manner with 'if', '1range' and '1fold' :

* ol mul !
12 dup [ 1 1range mul @ 1fold ] [ 0 ] if .eval

\ evaluated stack: [479001600]

Example of computing factorial of 12 in procedural manner with 'if' and 'while' :

12 dup [ 1 [ over * over 1 - ] while swap dp ] [ 0 ] if .eval

\ evaluated stack: [479001600]