Giter VIP home page Giter VIP logo

zen's Introduction

zen

A lightweight dynamically typed programming language written in Odin.

development

building

requirements

steps

Run the build script with the dbg arg to create a debug build:

./x.py dbg

This will produce a debug build as ./bin/dbg/zen. To produce a release build, run:

./x.py rel

testing

requirements

  • Odin
  • Ruby

steps

To test everything at once, run:

./x.py test

contributing

zen may have a lot of bugs and problems lying around, feel free to open an issue or create a pull request if you find any!

zen's People

Contributors

pes18fan avatar

Stargazers

Samrat Ghale avatar Prashant Gyawali avatar

Watchers

 avatar

zen's Issues

Segfault or `SIGABRT` on using `-S` flag on a program to test GC

To try and see if the GC is actually doing something, I was trying to make a program that made the GC do things. On running this program, ONLY when the GC is stressed using the -S flag:

class A {
    init() {
        this.x = 0
    }
}

{
    var obj = A()
}

The program stops, either via a segfault or a SIGABRT. The error message (on the fish shell) for the segfault is like this:

fish: Job 1, 'zen -S gc_test.zn' terminated by signal SIGSEGV (Address boundary error)

Or if it stops via SIGABRT it has something about realloc():

realloc(): Invalid pointer
fish: Job 1, 'zen -S gc_test.zn' terminated by signal SIGABRT (Abort)

On a bit of a closer look it appears that the program hasn't even started running when this error occurs, since adding the -T flag to trace script execution gives nothing. Adding the -D flag to dump disassembled bytecode however gives this:

== init ==
0000    3 OP_GET_LOCAL     0000
0002    | OP_CONSTANT      0001 '0'
0004    | OP_SET_PROPERTY  0000 'x'
0006    | OP_POP
0007    4 OP_GET_LOCAL     0000
0009    | OP_RETURN
realloc(): invalid pointer
fish: Job 1, 'zen -DSL gc_test.zn' terminated by signal SIGABRT (Abort)

It seems like the error might be occuring right as compilation ends, and before the VM starts. Again, the last error may be a SIGSEGV or a SIGABRT, but its still clear that something is wrong with the memory management.

Cross-platform terminal colors

Currently, the output of zen does provide colors (not a lot though, only the error messages are in color so far) but only on Unix-like shells. Windows shells like cmd.exe and PowerShell are out of luck.

As far as I'm aware, Odin does not have the capability to colorize input cross-platform, so I'm thinking of using some C code like in my watchlist project and importing it as a library to Odin to do this task.

Modules

Modules can be imported using the import keyword:

import "module.zn"

I'm still thinking about an export system; either JS-like or Lua-like.

As for how it works, it'll simply run any of the modules that have been imported so that the variables declared in the modules are added into the global scope so that the importing program can use them.

This is long-term, so it'll be a while before it is here.

Break statements are bugged

examples/demo.zn doesn't run correctly; upon inspection of the bytecode it was found that the break statement was bugged and was jumping to far greater distances than just outside of the loop, specifically the while true loop in the demo; which caused the VM's stack to misbehave and thus become empty before the end of the program.

This is probably an issue with how the jump offsets are calculated in the compiler, need to look into it further.

Fix closed over upvalues declared as `val` being reassignable

Variables inside a closure that have been declared as val are reassignable, despite val being for single-assign variables. This has been a known issue for a while, but I haven't been able to think of a way to fix it just yet so I haven't worked on it so far.

A program that represents this is as follows:

func outer() {
   func inner() {
       val x = "outside"
       return x
  }

   return inner
}

var y = outer()
y = "abcd"

This program should NOT compile, and must error when trying to create the var y; since vals can't be redeclared as vars either. The reassignability must not happen AT ALL.

Related to #11. That issue should should only be worked on once this is complete.

Compile error on using `it` more than once in a pipeline

When just playing around with the REPL, I discovered this weird issue:

Welcome to zen!
Press 'Ctrl-D' to exit.
zen:1> var x = 1
zen:2> x |> it + it
compile error at end: Expect ';' after expression.
  on [line 2]

This is supposed to print 2, not an error.

Seems to me like this is a bug in the compiler in the part responsible for compiling the it tokens. I assume it does not expect more than one its.

Check for variable existence at compile-time

Currently, checking for the existence of variables and erroring based on the result is done at runtime. It was only possible to do so at runtime at first; but after I added final variables (now vals), it has become possible to do so during compile time, as I had to do so to prevent reassignment or redeclaration of such variables.

The one challenge here is implementing such checking for upvalues, since the val checking hasn't yet been implemented for them either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.