Coder Social home page Coder Social logo

queso-lang / queso Goto Github PK

View Code? Open in Web Editor NEW
37.0 37.0 1.0 234 KB

๐Ÿง€ A delicious programming language

License: Apache License 2.0

TypeScript 100.00%
bytecode-interpreter dynamically-typed functional-programming interpreted-language language multi-paradigm-programming programming programming-language rust strongly-typed vm

queso's People

Contributors

judehunter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

73nko

queso's Issues

The idea of the null/nulling operator

The problem
Considering that the language uses the everything is an expression notion, it is sometimes hard not to return anything.
Example of how it can be done currently (in spec)

fn foo(x): {
  trace x; // trace x normally returns x which is not what we want here (for some reason)
  null; // we don't want to return anything (return null)
}

The solution

The ~ null-value may be a prefix operator which simply evaluates the following expression but returns null instead.

  • previous example done with the null operator:
fn foo(x): ~ trace x;
// the return value of trace x (which is x) is discarded

  • inside blocks:
fn foo(x, y): {
  bar(x);
  ~ trace y;
}

which might also be done this way (since a block is an expression):

fn foo(x, y): ~ {
  bar(x);
  trace y;
}

in my opinion this is extremely useful and makes a lot of sense.


  • control flow

for loops - normally they return an array made out of the return values of every iteration

fn foo(x, y): ~ for n in 0..5 -> trace n;
let bar = foo();

This is a useful tool implementation-wise. Here, with proper optimization, the array doesn't have to be created at all. That would be easy to implement even for examples such as:

fn foo(x, y): for n in 0..5 -> trace n;
let bar = ~ foo();

if..else if..else

fn foo(x, y):
  ~ if x -> trace x
  else if y -> trace y;

This simply returns nothing, no need for this:

fn foo(x, y):
  if x -> ~ trace x
  else if y -> ~ trace y;

Alternatives

  • Rust's semi or no-semi syntax
  • Use the return keyword always instead of returning the last thing in a block. This however is not really in the spirit of the language.

Add a --verbose flag

The problem
Currently, the interpreter spits out the bytecode instructions, which is needed for debugging, but is not disableable at this time, which creates a mess, sometimes.

The solution
Parse cli arguments and turn on or off debugging/verbose printing for certain parts of the interpreter.
Something like:

queso --verbose
queso --verbose=[toks,ast,instrs]

Fix how positions are stored inside a chunk

Currently, only the lines of the tokens are stored within the chunk (alongside instructions). Some are not even the correct lines.

The chunk should simply store the whole TokenPos.

Keyword expressions

Add support for the:

  • trace expression
  • return expression
  • throw expression
  • catch binary expression
  • async/await expressions

Read from file

  • Implement queso <file> in the CLI and in the interpreter
  • Add filename for trace and error reporting

Wrong resolving when dealing with blocks as expressions

Describe the bug

mut a = 5; trace a + {mut b = 3; b}

This should print 8, and yet it prints 10.
It has to do with the resolver assigning the first slot of the stack to a, and the second to b, but then the VM puts a on the first slot, then copies it to the second slot (because it's accessed after trace) and then b on the third slot instead of the second, so the last b actually copies a again.

Expected behavior
Prints 8.

Fix the infinite `expected an expression` loop

Describe the bug
When the parser gets ahold of a certain unexpected token (an identifier, for example) it start an infinite loop of

[1:0-1] Expected a SEMI after expression      
[1:0-1] Expected an expression

To Reproduce

  1. cargo run
  2. enter $ or thingy or . etc.

Expected behavior
The parser handles the error gracefully

AST visualisation

The problem
Currently, the AST visualisation is string based which is not the best.

The solution
Hook up graphviz or some other graph visualisation library.

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.