Giter Club home page Giter Club logo

yasl's People

Contributors

bobheadxi avatar coffeetableespresso avatar gadget114514 avatar nolongerbreathedin avatar randykdev avatar roetlich avatar ryco117 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  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

yasl's Issues

Features to implement

  • foreach loops (over 1 and 2 values, over all iterables)
    • over 1 value
    • over 2 values
  • list and table comprehensions (over 1 and 2 values, over all iterables)
    • list comprehensions
      • over 1 value
      • over 2 values
    • table comprehensions
      • over 1 value
      • over 2 values
  • metatables
  • garbage collector
  • importing files
  • regex (with matching operator)
  • operator overloading
  • infinity and nan

Types

add the following type literals:

  • float64
  • int64
  • bool
  • str8
  • list
  • map
  • file
  • type

add the following functions:

  • typeof (takes literal, returns type of that literal)

Add Builtins

  • add jump table for builtins
  • add builtin string functions
  • add builtin os functions

add `string.count` method

string->count(substring) returns the number of times substring appears in string (an int).

e.g.

'abc'->count('a') is 1 ('a' appears once in 'abc')
'xxxx'->count('xx') is 2 (we don't count overlapping occurrences of substring)

String Functions

  • contains
  • endswith
  • isal
  • isalnum
  • isnum
  • isspace
  • ltrim
  • replace
  • rtrim
  • search
  • split
  • startswith
  • trim

String escapes on single quoted strings

The following escapes should be valid in single quoted strings:

  • \b (backspace)
  • \f (formfeed)
  • \n (newline)
  • \r (carriage return)
  • \t (horizontal tab)
  • \v (vertical tab)
  • \ (backslash)
  • ' (single quote)
  • " (double quote)
  • \e (escape character)

This should be doable with changes only to lexer.c (and possibly lexer.h)

add string and list slicing

allow the notation s[a:b] for strings and lists. This is syntactic sugar for s->__slice(a, b). This returns a copy of s, starting from a and up to but not including b.

The following forms are allowed:

s[a:b] (s->__slice(a, b))
s[:b] (s->__slice(undef, b). For lists and strings, this is the same as s->__slice(0, b), but should decompose to the more general form with undef.)
s[a:] (s->__slice(a, undef). Similar to above example.)

The __slice method is mostly implemented already, but named slice currently (also, it does not support undef parameters, just int parameters.

Floating-point Exception on Optimization

In Makefile, setting an optimization flag (eg. "CFLAGS=-lm -O1") and then running this hailstone code

for i <- [1234567] {
while i > 1 {
  if i % 2 > 0 {
    i = 3*i+1
  } else {
    i = i//2
  }
  print i
}
}

will cause a segmentation fault. The same YASL script run with an Interpreter compiled with -O2 errors printing "Floating point exception (core dumped)".
The program prints nothing but the respective error message either time.

Travis

Get tests written in Perl working with Travis.

Scoped blocks

add blocks delimited only by {...} with lexical scoping.

Add IO library using C API

the following should be supported:

  • stdin, stdout, stderr
  • open(name, mode:="r")
  • close(file)
  • flush(file)
  • read(file, format)
  • write(file, value)
    seek(file, whence, offset)

once this is implemented, files should be removed from main interpreter

Add File functions/methods

add the following literals:

  • stdin
  • stdout
  • stderr

add the following functions:

  • open (opens file from string)
  • popen (runs string in shell, returns stdout of process run)

add the following methods:

  • write
  • read
  • readline
  • close
  • pclose

Raw strings delimited by backticks

user should be able to write strings delimited by backticks. No escape sequences or interpolation should happen in these strings (including no escaping of backticks or backslashes).

This change should be possible by changing only lexer.c (and possibly lexer.h)

Fix parser

Parser currently doesn't understand the precedence level of function calls.

Add method for sorting lists in place

list.sort method has the following semantics:

  • if all elements are strings, sort it lexically.
  • if all elements are numbers, sort it numerically.
  • otherwise, throw a type error.

e.g.
x := [4, 3, 1]; x->sort() (x is now [1, 3, 4])
x := ['a', 'c', 'b']; x->sort() (x is now ['a', 'b', 'c'])
x := [1, 'a']; x->sort() (type error)

Note that all the lexical comparisons for strings and numbers are already implemented, so feel free to use those.

Support Integer Division

Currently, all division operations result in a float64 object. This is not the expected/desired behaviour when both operands are integers, especially if the remainder is zero.

Suggested fix: support '//' operation to force integer division (floor result, return int64)

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.