From: Marc R. <re...@gm...> - 2024-10-06 15:24:07
|
I just pushed a new 'interpret' branch with updates to support a new INTERPRET instruction. These updates implement the INTERPRET instruction as in oorexx and regina, i.e. it will parse and execute (interpret) any (valid) NetRexx clauses in the context of the running program, with full access to variables, properties and methods. The included DiagInterpret.nrx unit test shows some of the capabilities: ===== Exec: DiagInterpret ===== >> i = i + 1 >> say 'i = 'i i = 1 >> i = callmethod(i) >> do;say 'i = 'i;end i = 2 >> j = callmethod(j) >> say 'j = 'j j = 2 >> k = j >> say 'k = 'k k = 2 >> if k \= 2 then signal DiagX('Failed create new var') Some faulty clauses to test --- Cannot parse clause : r = substr( --- Cannot parse clause : parse v v --- Cannot parse clause : i = 1/0 --- Cannot parse clause : i = i + --- Cannot parse clause : leave --- Block "do; i = 0" not properly ended --- Cannot parse clause : end --- Cannot parse clauses : end;end --- Cannot parse this "end: end;" >> loop forever; leave; end; >> if 1 then j = 3; else j = 2; >> if 0; then j = 3; else j = 2 >> select; when i = 1 then j = 3; when j = 3 then j = 4; otherwise; j = 1; finally; do;say 'i = 'i; say 'j = 'j; end;end i = 2 j = 1 >> interpret "interpret 'j = 0; say j'" 0 >> j = interpretreturn(j) >> return 1 DiagInterpret: OK! Obviously, the INTERPRET instruction is only supported when interpreting NetRexx. When compiling an INTERPET instruction, the translator will issue an error. Please test Marc |