Giter VIP home page Giter VIP logo

fml's People

Contributors

kondziu avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

fml's Issues

Scope of Variables inside Objects

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 with RUST_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?

Crash if the program consists of an unused function and nothing else

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:

  • With an empty input file, the parser returns a 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.
  • My interpreter first gets the instruction from the code vector (this is the index out of bounds), executes it, then breaks the loop if the instruction pointer has jumped out of the code vector. Moving this check to the start of the loop fixes the crash for me, maybe your interpreter does something similar.

Label -- Unique-problem

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.

fncinsideprint.zip

No such global error when trying to write a closure

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.

If no ENV variable is specified, fml runs twice using the script

FML/fml

Line 64 in 50869fb

$CMD $@

On this line it excecutes it if no ENV variable is specified, but then it continues parsing the commandline anyway and thus running it using the default parser, compiler, interpreter again

Possibly forgotten exit $?

Context:

FML/fml

Lines 62 to 77 in 50869fb

if $(not $parser_defined) && $(not $compiler_defined) && $(not $interpreter_defined)
then
$CMD $@
fi
# Run with substituted elements, first extract command and input file (if any)
command="$1"; shift
input="$1"; shift
case $command in
run) run "$input";;
parse) parse "$input" "$@";;
compile) compile "$input" "$@";;
execute) execute "$input" "$@";;
*) echo "Unknown command $command: with a specified custom parser, compiler, or interpreter I understand commands: run, parse, compile, and execute"
esac

Comparison of object and null is inconsistent

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.

Crash if multiple arrays require a loop to initialize

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

Escaping looks buggy

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.

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.