kondziu / fml Goto Github PK
View Code? Open in Web Editor NEWFML language and runtime
FML language and runtime
begin
let x = 20;
object begin
let Z = x;
let Y = object begin
let a = 4;
let b = Z;
end;
end;
end;
prints:
thread 'main' panicked at 'Get global error: no such global: Z', src/bytecode/interpreter.rs:618:18
note: run withRUST_BACKTRACE=1
environment variable to display a backtrace
object(a, b) cannot see variable Z in object(Z, Y), but Z can see variable x, Is that desired?
Example .fml file:
function f() -> print("x\n");
Error (using the run
command):
thread 'main' panicked at 'Interpreter error: Code address 0002 out of bounds (0..2)', src/main.rs:141:14
It works fine if the implicit global function contains anything else - e.g. just null
.
Version 1 doesn't crash.
My compiler+interpreter has pretty much the same bug - there are 2 causes:
Top
which contains a Null
node so there's 1 instruction in the generated code. With a file that contains a function but nothing else, the parser returns a Top
which contains the function but no other nodes so the implicit global function ends up having 0 instructions.After disecting a fml program
function a() -> 5
print("~\n", a())
(using v2 of fml compiler) the bytecode contains the instruction label indexcp01 (00 01 00)
twice.
To be more precise, the body of function a
is "copied" inside the body of "main" function (λ:)
Included in the zip file is the fml source (with possible extra semicolons, woops), the compiled bytecode and two disected .txt files -- one is pure bytecode, only "formatted" a bit, the second one is human readable version of said bytecode.
The spec states that globals refer to String program objects, see https://courses.fit.cvut.cz/NI-RUN/specs/bc.html#globals.
However, the reference compiler implementation seems to make it so that globals refer to Slot objects instead.
What is the intended behavior? Or am I missing something?
Code:
function f() -> begin
let local = 123;
let o = object begin
function m() -> local;
end;
o.m();
end;
f();
Error:
thread 'main' panicked at 'Interpreter error: Error evaluating get global #3:
Caused by:
No such global `local`.', src/main.rs:141:14
I guess FML doesn't support closures but it should probably error when compiling, not interpreting.
Code:
function x(a) -> a;
Error:
thread 'main' panicked at 'Interpreter error: Code address 0002 out of bounds (0..2)', src/main.rs:149:14
Comparison (== and !=) operators for custom object and null break equality symmetry.
For example:
let obj = object begin end;
print("~\n", obj == null); // true
print("~\n", null == obj); // false
The expected behavior in this case is for both to be false.
This program prints 5
- is that intended? If i uncomment the let
, then it crashes as expected.
begin
//let x = 4;
x <- 5;
end;
print("~\n", x);
Code:
let a1 = array(123, 1+1);
let a2 = array(456, 2+2);
Error:
thread 'main' panicked at 'Cannot register new global ::size: Cannot register global `#3`, index is already registered as a global.', src/bytecode/compiler.rs:273:30
print("\~\n", 5);
prints 5\n
(without a newline).
print("\~\~\n", 5, 5);
prints 5\5
(with a newline).
The spec says "~ converts to the character ~" - is that supposed to mean it prints a ~
or that it behaves the same as ~
? If it behaves the same (it almost does now), there's no way to print a literal ~
.
There's also no way to print a \
according to the spec.
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.