Navigation
|
Synopsis Evaluate a (list of) Rascal commands and return the value of the last command.
Function -
Result[&T] eval(type[&T] typ, str command) throws Timeout, StaticError, ParseError
-
Result[value] eval(str command)
-
Result[&T] eval(type[&T] typ, list[str] commands) throws Timeout, StaticError, ParseError
-
Result[value] eval(list[str] commands)
-
Result[&T] eval(type[&T] typ, str command, int duration) throws Timeout, StaticError, ParseError
-
Result[value] eval(str command, int duration)
-
Result[&T] eval(type[&T] typ, list[str] commands, int duration) throws Timeout, StaticError, ParseError
-
Result[value] eval(list[str] commands, int duration)
Usage import util::Eval;
Description Evaluate a command or a list of commands and return the value of the last command that is executed.
Note that a command can be one of:
- Statement
- Declaration
- Import
- Extend
- SyntaxDefinition
The notable exclusion are Expressions. An Expression is not allowed as a command to the eval function. You can easily make
a Statement from an Expression by adding a semi-colon.
An optional duration argument may be present to limit the time
(in milliseconds) the execution may take. By default, the duration is set to 1000 ms.
Examples rascal>import util::Eval;
ok
rascal>eval("2 * 3;");
Result[value]: result(6)
rascal>eval(["X = 2 * 3;", "X + 5;"]);
Result[value]: result(11)
|