Search code examples
command-linerascal

Is it possible to run rascal programs from the command line?


I know how to run rascal code from within eclipse and how to use the REPL, but I don't know how I can run a rascal file (or group of rascal files) as a program from the command line.

When I try the following, I get a parse error:

$ java -Xmx1G -Xss32m -jar rascal-shell-stable.jar mymodule.rsc
Version: 0.7.2.201501130937
Parse error in cwd:///mymodule.rsc from <1,11> to <1,12>

The contents of mymodule.rsc:

module mymodule

println("hello world");

What am I doing wrong?


Solution

  • Well, your mymodule.rsc is actually syntactically incorrect and will also give parse errors in the Eclipse IDE. Here is an improved version:

    module mymodule
    
    import IO;
    
    value main(list[value] args) {
        println("hello world");
    }
    

    Bonus: you should also add import IO; to make the println function available.