JSPM

  • Created
  • Published
  • Downloads 5
  • Score
    100M100P100Q29020F
  • License MIT

educational scripting language / shell with read-eval-print loop

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (pyxlang) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    pyx scripting language

    PUX - link to youtube video - the pyx educational programming language / scripting langauge and REPL shell. With pyx you can write code in functional and procedural style.

    This programming language is named after Winnie-the-Pooh, in the Russian translation of Boris Zahoder

    The scripting language and interpreter for the pyx language.

    Running it

    First we need the to install node.js - you can download an installer here

    Now, from the command line: Install the pyx shell with the following command

    npm install pyxlang -g

    Now run the shell

    pyx

    The shell has command completion (tab tab) and a command history (cursor up, cursor down)

    You can also run one-line commands as follows

    pyx -e 'println("hello world")'

    or run any saved source file with

    pyx source.p

    You can also run the program in trace mode, by adding the -x option to the command line. Here each statement is shown, as it is executed.

    ./pyx -x tests/03-func-if.p
    foo(val=6)
    + if true
    + println("should be happy years") {
    should be happy years
    + }
    + }
    foo(val=20)
    + if false # <pass>
    + elif true
    + println("youth age") {
    youth age
    + }
    + }
    foo(val=42)
    + if false # <pass>
    + elif false # <pass>
    + else
    + println("after youth age") {
    after youth age
    + }
    + }
    + }

    Source code

    • the interpreter/repl script is here - you need to have node installed for this.
    • The parser/syntax tree is built here the runtime for the interpeter is here

    what I learned while writing this project

    Writing a programming languages is a whole lot of work. Doing a small programming language makes me appreciate the authors of the tools that i am using everyday. Someone who is implementing a language has to take care of all the detail, a programmer who is using that language is spared this effort, that's something to appreciate!

    There is an awfull amount of detail hidden within a programming languages. Now this reminds me of the movies of Stanley Kubrick. Kubrick was obsessed with putting meaning into detail, i guess he would have liked the exercise of writing a programming language... (more info in this documentary )

    Another thing: i am learning about interpreted languages (such as python, php, javascript, perl, etc...) Now I keep noticing quite a lot of details, while writing my little interpreter. I am keeping some notes here

    The moral: you can learn a lot with this type of project! (i think the important part is to keep notes, otherwise you tend to forget the details...)