Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,4 +1,5 @@
|
|||
Demonstrate your language's ability for programs to execute code written in the language provided at runtime. Show us what kind of program fragments are permitted (e.g. expressions vs. statements), how you get values in and out (e.g. environments, arguments, return values), if applicable what lexical/static environment the program is evaluated in, and what facilities for restricting (e.g. sandboxes, resource limits) or customizing (e.g. debugging facilities) the execution.
|
||||
Demonstrate your language's ability for programs to execute code written in the language provided at runtime.
|
||||
Show us what kind of program fragments are permitted (e.g. expressions vs. statements), how you get values in and out (e.g. environments, arguments, return values), if applicable what lexical/static environment the program is evaluated in, and what facilities for restricting (e.g. sandboxes, resource limits) or customizing (e.g. debugging facilities) the execution.
|
||||
|
||||
You may not invoke a separate evaluator program, or invoke a compiler and then its output, unless the interface of that program, and the syntax and means of executing it, are considered part of your language/library/platform.
|
||||
|
||||
|
|
|
|||
35
Task/Runtime-evaluation/ALGOL-68/runtime-evaluation-2.alg
Normal file
35
Task/Runtime-evaluation/ALGOL-68/runtime-evaluation-2.alg
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
# procedure to call the Algol 68G evaluate procedure #
|
||||
# the environment of the evaluation will be the caller's environment #
|
||||
# with "code", "x" and "y" defined as the procedure parameters #
|
||||
PROC ev = ( STRING code, INT x, INT y )STRING: evaluate( code );
|
||||
|
||||
BEGIN
|
||||
|
||||
INT i := 1;
|
||||
INT j := 2;
|
||||
REAL x := 4.2;
|
||||
REAL y := 0.7164;
|
||||
|
||||
# evaluates "i + j" in the current environment #
|
||||
print( ( evaluate( "i + j" ), newline ) );
|
||||
|
||||
# evaluates "x + y" in the environment of the procedure body of ev #
|
||||
print( ( ev( "x + y", i, j ), newline ) );
|
||||
|
||||
# evaluates "x + y" in the current environment, so shows a different #
|
||||
# result to the previous call #
|
||||
print( ( evaluate( "x + y" ), newline ) );
|
||||
|
||||
# prints "code" because code is defined in the environment of the #
|
||||
# call to evaluate (in ev) although it is not defined in this #
|
||||
# environment #
|
||||
print( ( ev( "code", 1, 2 ), newline ) );
|
||||
|
||||
# prints "code + codecode + code" - see above #
|
||||
print( ( ev( "code + code", 1, 2 ), newline ) )
|
||||
|
||||
END
|
||||
|
||||
# if this next call was executed, a runtime error would occur as x and y #
|
||||
# do not exist anymore #
|
||||
# ;print( ( evaluate( "x + y" ), newline ) ) #
|
||||
1
Task/Runtime-evaluation/Frink/runtime-evaluation.frink
Normal file
1
Task/Runtime-evaluation/Frink/runtime-evaluation.frink
Normal file
|
|
@ -0,0 +1 @@
|
|||
eval["length = 1234 feet + 2 inches"]
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
def context = new B inding()
|
||||
def context = new Binding()
|
||||
context.startYear = 2008
|
||||
context.endYear = 2121
|
||||
def years3 = new GroovyShell(context).evaluate('''
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
def years4 = new GroovyShell( new B inding(startYear: 2008, endYear: 2121) ).evaluate('''
|
||||
def years4 = new GroovyShell( new Binding(startYear: 2008, endYear: 2121) ).evaluate('''
|
||||
(startYear..endYear).findAll {
|
||||
Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
def binding = new B inding(startYear: 2008, endYear: 2121)
|
||||
def binding = new Binding(startYear: 2008, endYear: 2121)
|
||||
new GroovyShell( binding ).evaluate('''
|
||||
yearList = (startYear..endYear).findAll {
|
||||
Date.parse("yyyy-MM-dd", "${it}-12-25").format("EEE") == "Sun"
|
||||
|
|
|
|||
2
Task/Runtime-evaluation/Lua/runtime-evaluation-2.lua
Normal file
2
Task/Runtime-evaluation/Lua/runtime-evaluation-2.lua
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
f = load("return 42")
|
||||
f() --> returns 42
|
||||
37
Task/Runtime-evaluation/MATLAB/runtime-evaluation.m
Normal file
37
Task/Runtime-evaluation/MATLAB/runtime-evaluation.m
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
function testEval
|
||||
fprintf('Expressions:\n')
|
||||
x = eval('5+10^2')
|
||||
eval('y = (x-100).*[1 2 3]')
|
||||
eval('z = strcat(''my'', '' string'')')
|
||||
try
|
||||
w eval(' = 45')
|
||||
catch
|
||||
fprintf('Runtime error: interpretation of w is a function\n\n')
|
||||
end
|
||||
% eval('v') = 5
|
||||
% Invalid at compile-time as MATLAB interprets as using eval as a variable
|
||||
|
||||
fprintf('Other Statements:\n')
|
||||
nl = sprintf('\n');
|
||||
eval(['for k = 1:20' nl ...
|
||||
'fprintf(''%.3f\n'', k)' nl ...
|
||||
'if k == 3' nl ...
|
||||
'break' nl ...
|
||||
'end' nl ...
|
||||
'end'])
|
||||
true == eval('1')
|
||||
try
|
||||
true eval(' == 1')
|
||||
catch
|
||||
fprintf('Runtime error: interpretation of == 1 is of input to true\n\n')
|
||||
end
|
||||
|
||||
fprintf('Programming on the fly:\n')
|
||||
userIn = true;
|
||||
codeBlock = '';
|
||||
while userIn
|
||||
userIn = input('Enter next line of code: ', 's');
|
||||
codeBlock = [codeBlock nl userIn];
|
||||
end
|
||||
eval(codeBlock)
|
||||
end
|
||||
3
Task/Runtime-evaluation/REBOL/runtime-evaluation.rebol
Normal file
3
Task/Runtime-evaluation/REBOL/runtime-evaluation.rebol
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
a: -5
|
||||
b: 7
|
||||
answer: do [abs a * b] ; => 35
|
||||
|
|
@ -1,12 +1,12 @@
|
|||
/*REXX program to illustrate ability to execute code written at runtime.*/
|
||||
numeric digits 10000000
|
||||
/*REXX program illustrates ability to execute code entered at "runtime".*/
|
||||
numeric digits 10000000 /*ten million digits should do it*/
|
||||
bee=51
|
||||
stuff='bee=min(-2,44); say 13*2 "[from inside the box."; abc=abs(bee)'
|
||||
stuff= 'bee=min(-2,44); say 13*2 "[from inside the box.]"; abc=abs(bee)'
|
||||
interpret stuff
|
||||
say 'bee=' bee
|
||||
say 'abc=' abc
|
||||
say
|
||||
|
||||
/* [↓] now, we hear from da user*/
|
||||
say 'enter an expression:'
|
||||
pull expression
|
||||
say
|
||||
|
|
@ -16,7 +16,7 @@ interpret '?='expression
|
|||
|
||||
say
|
||||
say 'length of result='length(?)
|
||||
say ' left 50 bytes of result='left(?,50)'...'
|
||||
say 'right 50 bytes of result=...'right(?,50)
|
||||
say ' left 50 bytes of result='left(?,50)'···'
|
||||
say 'right 50 bytes of result=···'right(?,50)
|
||||
|
||||
/*stick a fork in it, we're done.*/
|
||||
|
|
|
|||
4
Task/Runtime-evaluation/UNIX-Shell/runtime-evaluation.sh
Normal file
4
Task/Runtime-evaluation/UNIX-Shell/runtime-evaluation.sh
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
$ a=42
|
||||
$ b=a
|
||||
$ eval "echo \$$b"
|
||||
42
|
||||
Loading…
Add table
Add a link
Reference in a new issue