yasl-lang / yasl Goto Github PK
View Code? Open in Web Editor NEWBytecode Interpreter for Yet Another Scripting Language (YASL).
License: MIT License
Bytecode Interpreter for Yet Another Scripting Language (YASL).
License: MIT License
for i, val <- ls { ... }
The following escapes should be valid in single quoted strings:
This should be doable with changes only to lexer.c (and possibly lexer.h)
add the following type literals:
add the following functions:
When executing print ["A", "B"]
interpreter prints the location in memory of the list instead of something meaningful (like a recursive call on its contents' toString() .)
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.
add in
operator.
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)
use this to implement break
and continue
.
the following should be supported:
once this is implemented, files should be removed from main interpreter
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)
add classes.
add blocks delimited only by {...}
with lexical scoping.
add the following literals:
add the following functions:
add the following methods:
see here for examples of where underscores are allowed.
Must be supported by literals, str.tofloat
, and str.toint
.
prevent infinite loops from causing a segfault.
Parser currently doesn't understand the precedence level of function calls.
e.g.
for let x in ls {
print x
}
Get tests written in Perl working with Travis.
YASL functions currently trim or extend the argument list passed to match the number of arguments expected. Make C functions do the same.
list.sort
method has the following semantics:
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.
and continue
I did a cheap hack when I first implemented for-loops (added a second stack to store their values). This should be fixed so that only 1 stack is used for everything.
After this is done, exponentiation should be the only thing that depends on math.h
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)
Add strings.
interpolated strings should accept all escapes that single quoted strings accept, plus string interpolation using a # character.
add lists
e.g.
for let x = 1; x < 20; x += 1 {
print x
}
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.
rewrite the whole Python part in C
Compiler flag issues
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.