From 67b13aea331f9a261dcbe01c1cd1ab653902aafb Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 24 Nov 2020 16:04:36 -0500 Subject: [PATCH] accept-case case-c-dsl-user-defined-functions-and-subroutines.sh --- go/cases-to-do.txt | 4 - ...-user-defined-functions-and-subroutines.sh | 15 +- ...r-defined-functions-and-subroutines.sh.out | 446 +++--------------- 3 files changed, 66 insertions(+), 399 deletions(-) diff --git a/go/cases-to-do.txt b/go/cases-to-do.txt index 58ebd18e1..b5578ad29 100644 --- a/go/cases-to-do.txt +++ b/go/cases-to-do.txt @@ -1,10 +1,6 @@ ================================================================ BUG: -rrv ./reg-test/cases/case-c-dsl-user-defined-functions-and-subroutines.sh -* emit-with-redirect -* also print/output sequencing issue (fix in test) - rrv ./reg-test/cases/case-c-dsl-for-srec-loops.sh * mlr --from ./reg-test/input/abixy put -S -v 'for(k,v in $*) {$[v]=k}' Miller: record/map indices must be string or positional-int; got float diff --git a/go/reg-test/cases/case-c-dsl-user-defined-functions-and-subroutines.sh b/go/reg-test/cases/case-c-dsl-user-defined-functions-and-subroutines.sh index 5f7d358cd..de5955538 100644 --- a/go/reg-test/cases/case-c-dsl-user-defined-functions-and-subroutines.sh +++ b/go/reg-test/cases/case-c-dsl-user-defined-functions-and-subroutines.sh @@ -50,12 +50,19 @@ mlr_expect_fail --from $indir/abixy put ' # Test fencing: function f should not have access to boundvar k from the callsite. run_mlr --from $indir/abixy --opprint put 'func f(x) {return k} for (k,v in $*) {$o=f($x)}' -run_mlr --from $indir/abixy --opprint put 'subr foo() {print "k is [".k."]"} for (k,v in $*) {call foo()}' +run_mlr --from $indir/2.dkvp --opprint put -q ' + subr foo() { + print "k is [".k."]" + } + for (k,v in $*) { + call foo() + } +' # Test overriding built-ins mlr_expect_fail --opprint --from $indir/abixy put 'func log(x) { return 0 } $o = log($x)' -run_mlr --from $indir/abixy put 'subr log() { print "hello record ". NR } call log()' +run_mlr --from $indir/abixy put -q 'subr log() { print "hello record ". NR } call log()' # No nesting of top-levels mlr_expect_fail --from $indir/abixy --opprint put 'func f(x) { begin {} }' @@ -86,7 +93,7 @@ mlr_expect_fail --from $indir/abixy --opprint put 'subr s() { } subr s(x) { }' run_mlr --from $indir/abixy --opprint put 'subr log(text) { print "TEXT IS ".text } call log("NR is ".NR)' # scoping within distinct begin/end blocks -run_mlr --from $indir/abixy put -v ' +run_mlr --from $indir/abixy --opprint put ' func f(x) { return x**2 } @@ -124,6 +131,6 @@ run_mlr --from $indir/abixy put -v ' # print/dump from subr/func; no tee/emit from func run_mlr --from $indir/abixy --opprint put 'subr log(text) { print "TEXT IS ".text } call log("NR is ".NR)' run_mlr --from $indir/abixy --opprint put 'func f(text) { print "TEXT IS ".text; return text.text } $o = f($a)' -run_mlr --from $indir/abixy put 'begin{@x=1} func f(x) { dump; print "hello" } $o=f($i)' +run_mlr --from $indir/abixy --opprint put 'begin{@x=1} func f(x) { dump; print "hello" } $o=f($i)' mlr_expect_fail --from $indir/abixy put 'begin{@x=1} func f(x) { dump; print "hello"; tee > "x", $* } $o=f($i)' mlr_expect_fail --from $indir/abixy put 'begin{@x=1} func f(x) { dump; print "hello"; emit > "x", @* } $o=f($i)' diff --git a/go/reg-test/expected/case-c-dsl-user-defined-functions-and-subroutines.sh.out b/go/reg-test/expected/case-c-dsl-user-defined-functions-and-subroutines.sh.out index 1766b3e5a..05dba5c63 100644 --- a/go/reg-test/expected/case-c-dsl-user-defined-functions-and-subroutines.sh.out +++ b/go/reg-test/expected/case-c-dsl-user-defined-functions-and-subroutines.sh.out @@ -23,17 +23,17 @@ mlr --opprint --from ./reg-test/input/abixy put $o = f($x, $y, $i); call s("W", NR); -a b i x y o W DID -pan pan 1 0.3467901443380824 0.7268028627434533 2.073593 1 YES -eks pan 2 0.7586799647899636 0.5221511083334797 3.280831 2 YES -wye wye 3 0.20460330576630303 0.33831852551664776 3.542922 3 YES -eks wye 4 0.38139939387114097 0.13418874328430463 4.515588 4 YES -wye pan 5 0.5732889198020006 0.8636244699032729 6.436913 5 YES -zee pan 6 0.5271261600918548 0.49322128674835697 7.020347 6 YES -eks zee 7 0.6117840605678454 0.1878849191181694 7.799669 7 YES -zee wye 8 0.5985540091064224 0.976181385699006 9.574735 8 YES -hat wye 9 0.03144187646093577 0.7495507603507059 9.780993 9 YES -pan wye 10 0.5026260055412137 0.9526183602969864 11.455244 10 YES +a b i x y o W DID +pan pan 1 0.3467901443380824 0.7268028627434533 2.0735930070815356 1 YES +eks pan 2 0.7586799647899636 0.5221511083334797 3.2808310731234434 2 YES +wye wye 3 0.20460330576630303 0.33831852551664776 3.5429218312829507 3 YES +eks wye 4 0.38139939387114097 0.13418874328430463 4.515588137155445 4 YES +wye pan 5 0.5732889198020006 0.8636244699032729 6.436913389705273 5 YES +zee pan 6 0.5271261600918548 0.49322128674835697 7.020347446840212 6 YES +eks zee 7 0.6117840605678454 0.1878849191181694 7.799668979686015 7 YES +zee wye 8 0.5985540091064224 0.976181385699006 9.574735394805428 8 YES +hat wye 9 0.03144187646093577 0.7495507603507059 9.780992636811641 9 YES +pan wye 10 0.5026260055412137 0.9526183602969864 11.455244365838201 10 YES mlr --opprint --from ./reg-test/input/abixy put func f(x,y,z) { @@ -47,17 +47,17 @@ mlr --opprint --from ./reg-test/input/abixy put $o = f($x, $y, $i); call s("W", NR); -a b i x y o W -pan pan 1 0.3467901443380824 0.7268028627434533 2.073593 1 -eks pan 2 0.7586799647899636 0.5221511083334797 3.280831 2 -wye wye 3 0.20460330576630303 0.33831852551664776 3.542922 3 -eks wye 4 0.38139939387114097 0.13418874328430463 4.515588 4 -wye pan 5 0.5732889198020006 0.8636244699032729 6.436913 5 -zee pan 6 0.5271261600918548 0.49322128674835697 7.020347 6 -eks zee 7 0.6117840605678454 0.1878849191181694 7.799669 7 -zee wye 8 0.5985540091064224 0.976181385699006 9.574735 8 -hat wye 9 0.03144187646093577 0.7495507603507059 9.780993 9 -pan wye 10 0.5026260055412137 0.9526183602969864 11.455244 10 +a b i x y o W +pan pan 1 0.3467901443380824 0.7268028627434533 2.0735930070815356 1 +eks pan 2 0.7586799647899636 0.5221511083334797 3.2808310731234434 2 +wye wye 3 0.20460330576630303 0.33831852551664776 3.5429218312829507 3 +eks wye 4 0.38139939387114097 0.13418874328430463 4.515588137155445 4 +wye pan 5 0.5732889198020006 0.8636244699032729 6.436913389705273 5 +zee pan 6 0.5271261600918548 0.49322128674835697 7.020347446840212 6 +eks zee 7 0.6117840605678454 0.1878849191181694 7.799668979686015 7 +zee wye 8 0.5985540091064224 0.976181385699006 9.574735394805428 8 +hat wye 9 0.03144187646093577 0.7495507603507059 9.780992636811641 9 +pan wye 10 0.5026260055412137 0.9526183602969864 11.455244365838201 10 mlr --from ./reg-test/input/abixy put func f(x,y,z) { @@ -70,7 +70,6 @@ mlr --from ./reg-test/input/abixy put $o = f($x, $y, $i); call s("W", NR); -mlr: return statements within user-defined subroutines must not return a value. mlr --from ./reg-test/input/abixy put func f(x,y,z) { @@ -82,7 +81,6 @@ mlr --from ./reg-test/input/abixy put $o = f($x, $y, $i); call s("W", NR); -mlr: return statements within user-defined functions must return a value. mlr --from ./reg-test/input/abixy --opprint put func f(x) {return k} for (k,v in $*) {$o=f($x)} a b i x y @@ -97,7 +95,14 @@ zee wye 8 0.5985540091064224 0.976181385699006 hat wye 9 0.03144187646093577 0.7495507603507059 pan wye 10 0.5026260055412137 0.9526183602969864 -mlr --from ./reg-test/input/abixy --opprint put subr foo() {print "k is [".k."]"} for (k,v in $*) {call foo()} +mlr --from ./reg-test/input/2.dkvp --opprint put -q + subr foo() { + print "k is [".k."]" + } + for (k,v in $*) { + call foo() + } + k is [] k is [] k is [] @@ -108,142 +113,60 @@ k is [] k is [] k is [] k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -k is [] -a b i x y -pan pan 1 0.3467901443380824 0.7268028627434533 -eks pan 2 0.7586799647899636 0.5221511083334797 -wye wye 3 0.20460330576630303 0.33831852551664776 -eks wye 4 0.38139939387114097 0.13418874328430463 -wye pan 5 0.5732889198020006 0.8636244699032729 -zee pan 6 0.5271261600918548 0.49322128674835697 -eks zee 7 0.6117840605678454 0.1878849191181694 -zee wye 8 0.5985540091064224 0.976181385699006 -hat wye 9 0.03144187646093577 0.7495507603507059 -pan wye 10 0.5026260055412137 0.9526183602969864 mlr --opprint --from ./reg-test/input/abixy put func log(x) { return 0 } $o = log($x) -mlr: function named "log" must not override a built-in function of the same name. -mlr --from ./reg-test/input/abixy put subr log() { print "hello record ". NR } call log() +mlr --from ./reg-test/input/abixy put -q subr log() { print "hello record ". NR } call log() hello record 1 -a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533 hello record 2 -a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797 hello record 3 -a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776 hello record 4 -a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463 hello record 5 -a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729 hello record 6 -a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697 hello record 7 -a=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694 hello record 8 -a=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006 hello record 9 -a=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059 hello record 10 -a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864 mlr --from ./reg-test/input/abixy --opprint put func f(x) { begin {} } -mlr: begin statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put func f(x) { end {} } -mlr: end statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put subr s(x) { begin {} } -mlr: begin statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put subr s(x) { end {} } -mlr: end statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put func f(x) { func g(y) {} } -mlr: func statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put func f(x) { subr t(y) {} } -mlr: subr statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put subr s(x) { func g(y) {} } -mlr: func statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put subr s(x) { subr t(y) {} } -mlr: subr statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter func f(x) { begin {} }; true -mlr: begin statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter func f(x) { end {} }; true -mlr: end statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter subr s(x) { begin {} }; true -mlr: begin statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter subr s(x) { end {} }; true -mlr: end statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter func f(x) { func g(y) {} }; true -mlr: func statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter func f(x) { subr t(y) {} }; true -mlr: subr statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter subr s(x) { func g(y) {} }; true -mlr: func statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint filter subr s(x) { subr t(y) {} }; true -mlr: subr statements are only valid at top level. mlr --from ./reg-test/input/abixy --opprint put func log(x) { return $x + 1 } -mlr: function named "log" must not override a built-in function of the same name. mlr --from ./reg-test/input/abixy --opprint put func f(x) { return $x + 1 } func f(x) { return $x + 1} -mlr: function named "f" has already been defined. mlr --from ./reg-test/input/abixy --opprint put subr s() { } subr s() { } -mlr: subroutine named "s" has already been defined. mlr --from ./reg-test/input/abixy --opprint put subr s() { } subr s(x) { } -mlr: subroutine named "s" has already been defined. mlr --from ./reg-test/input/abixy --opprint put subr log(text) { print "TEXT IS ".text } call log("NR is ".NR) TEXT IS NR is 1 @@ -268,7 +191,7 @@ zee wye 8 0.5985540091064224 0.976181385699006 hat wye 9 0.03144187646093577 0.7495507603507059 pan wye 10 0.5026260055412137 0.9526183602969864 -mlr --from ./reg-test/input/abixy put -v +mlr --from ./reg-test/input/abixy --opprint put func f(x) { return x**2 } @@ -302,279 +225,21 @@ mlr --from ./reg-test/input/abixy put -v print "local4 = ".emm; } -RAW AST: - -AST ROOT: -text="block", type=STATEMENT_BLOCK: - text="f", type=FUNC_DEF: - text="f", type=NON_SIGIL_NAME: - text="x", type=UNTYPED_PARAMETER_DEFINITION. - text="func_block", type=STATEMENT_BLOCK: - text="return_value", type=RETURN_VALUE: - text="**", type=OPERATOR: - text="x", type=NONINDEXED_LOCAL_VARIABLE. - text="2", type=NUMERIC_LITERAL. - text="g", type=FUNC_DEF: - text="g", type=NON_SIGIL_NAME: - text="y", type=UNTYPED_PARAMETER_DEFINITION. - text="func_block", type=STATEMENT_BLOCK: - text="return_value", type=RETURN_VALUE: - text="+", type=OPERATOR: - text="y", type=NONINDEXED_LOCAL_VARIABLE. - text="1", type=NUMERIC_LITERAL. - text="s", type=SUBR_DEF: - text="s", type=NON_SIGIL_NAME: - text="a", type=UNTYPED_PARAMETER_DEFINITION. - text="b", type=UNTYPED_PARAMETER_DEFINITION. - text="c", type=UNTYPED_PARAMETER_DEFINITION. - text="subr_block", type=STATEMENT_BLOCK: - text="print", type=PRINT: - text=".", type=OPERATOR: - text=".", type=OPERATOR: - text="a", type=NONINDEXED_LOCAL_VARIABLE. - text="b", type=NONINDEXED_LOCAL_VARIABLE. - text="c", type=NONINDEXED_LOCAL_VARIABLE. - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - text="begin", type=BEGIN: - text="begin_block", type=STATEMENT_BLOCK: - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="0", type=NUMERIC_LITERAL. - text="var", type=UNTYPED_LOCAL_DEFINITION: - text="ell", type=NONINDEXED_LOCAL_VARIABLE. - text="1", type=NUMERIC_LITERAL. - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local1 = ", type=STRING_LITERAL. - text="ell", type=NONINDEXED_LOCAL_VARIABLE. - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - text="end", type=END: - text="end_block", type=STATEMENT_BLOCK: - text="emit", type=EMIT: - text="emit", type=EMIT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="stream", type=STREAM: - text="var", type=UNTYPED_LOCAL_DEFINITION: - text="emm", type=NONINDEXED_LOCAL_VARIABLE. - text="2", type=NUMERIC_LITERAL. - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local2 = ", type=STRING_LITERAL. - text="emm", type=NONINDEXED_LOCAL_VARIABLE. - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="+", type=OPERATOR: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="1", type=NUMERIC_LITERAL. - text="begin", type=BEGIN: - text="begin_block", type=STATEMENT_BLOCK: - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="0", type=NUMERIC_LITERAL. - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="0", type=NUMERIC_LITERAL. - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local3 = ", type=STRING_LITERAL. - text="ell", type=NONINDEXED_LOCAL_VARIABLE. - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="+", type=OPERATOR: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="2", type=NUMERIC_LITERAL. - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="+", type=OPERATOR: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="3", type=NUMERIC_LITERAL. - text="end", type=END: - text="end_block", type=STATEMENT_BLOCK: - text="emit", type=EMIT: - text="emit", type=EMIT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="stream", type=STREAM: - text="emit", type=EMIT: - text="emit", type=EMIT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="stream", type=STREAM: - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local4 = ", type=STRING_LITERAL. - text="emm", type=NONINDEXED_LOCAL_VARIABLE. - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - -BLOCKED AST: - -FUNCTION DEFINITION: -text="f", type=FUNC_DEF: subframe_var_count=2 max_subframe_depth=1 max_var_depth=2 - text="f", type=NON_SIGIL_NAME: - text="x", type=UNTYPED_PARAMETER_DEFINITION. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="func_block", type=STATEMENT_BLOCK: - text="return_value", type=RETURN_VALUE: - text="**", type=OPERATOR: - text="x", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="2", type=NUMERIC_LITERAL. - -FUNCTION DEFINITION: -text="g", type=FUNC_DEF: subframe_var_count=2 max_subframe_depth=1 max_var_depth=2 - text="g", type=NON_SIGIL_NAME: - text="y", type=UNTYPED_PARAMETER_DEFINITION. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="func_block", type=STATEMENT_BLOCK: - text="return_value", type=RETURN_VALUE: - text="+", type=OPERATOR: - text="y", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="1", type=NUMERIC_LITERAL. - -SUBROUTINE DEFINITION: -text="s", type=SUBR_DEF: subframe_var_count=4 max_subframe_depth=1 max_var_depth=4 - text="s", type=NON_SIGIL_NAME: - text="a", type=UNTYPED_PARAMETER_DEFINITION. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="b", type=UNTYPED_PARAMETER_DEFINITION. vardef_subframe_relative_index=2 vardef_subframe_index=0 vardef_frame_relative_index=2 - text="c", type=UNTYPED_PARAMETER_DEFINITION. vardef_subframe_relative_index=3 vardef_subframe_index=0 vardef_frame_relative_index=3 - text="subr_block", type=STATEMENT_BLOCK: - text="print", type=PRINT: - text=".", type=OPERATOR: - text=".", type=OPERATOR: - text="a", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="b", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=2 vardef_subframe_index=0 vardef_frame_relative_index=2 - text="c", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=3 vardef_subframe_index=0 vardef_frame_relative_index=3 - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - -BEGIN-BLOCK: -text="begin", type=BEGIN: subframe_var_count=2 max_subframe_depth=1 max_var_depth=2 - text="begin_block", type=STATEMENT_BLOCK: - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="0", type=NUMERIC_LITERAL. - text="var", type=UNTYPED_LOCAL_DEFINITION: - text="ell", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="1", type=NUMERIC_LITERAL. - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local1 = ", type=STRING_LITERAL. - text="ell", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - -BEGIN-BLOCK: -text="begin", type=BEGIN: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1 - text="begin_block", type=STATEMENT_BLOCK: - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="0", type=NUMERIC_LITERAL. - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="0", type=NUMERIC_LITERAL. - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local3 = ", type=STRING_LITERAL. - text="ell", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=0 vardef_subframe_index=0 vardef_frame_relative_index=0 - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - -END-BLOCK: -text="end", type=END: subframe_var_count=2 max_subframe_depth=1 max_var_depth=2 - text="end_block", type=STATEMENT_BLOCK: - text="emit", type=EMIT: - text="emit", type=EMIT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="stream", type=STREAM: - text="var", type=UNTYPED_LOCAL_DEFINITION: - text="emm", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text="2", type=NUMERIC_LITERAL. - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local2 = ", type=STRING_LITERAL. - text="emm", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=1 vardef_subframe_index=0 vardef_frame_relative_index=1 - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - -END-BLOCK: -text="end", type=END: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1 - text="end_block", type=STATEMENT_BLOCK: - text="emit", type=EMIT: - text="emit", type=EMIT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="stream", type=STREAM: - text="emit", type=EMIT: - text="emit", type=EMIT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="stream", type=STREAM: - text="print", type=PRINT: - text=".", type=OPERATOR: - text="local4 = ", type=STRING_LITERAL. - text="emm", type=NONINDEXED_LOCAL_VARIABLE. vardef_subframe_relative_index=0 vardef_subframe_index=0 vardef_frame_relative_index=0 - text=">", type=FILE_WRITE: - text="stdout", type=STDOUT: - -MAIN BLOCK: -text="main_block", type=STATEMENT_BLOCK: subframe_var_count=1 max_subframe_depth=1 max_var_depth=1 - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="+", type=OPERATOR: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="a", type=STRING_LITERAL. - text="1", type=NUMERIC_LITERAL. - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="+", type=OPERATOR: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="b", type=STRING_LITERAL. - text="2", type=NUMERIC_LITERAL. - text="=", type=OOSVAR_ASSIGNMENT: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="+", type=OPERATOR: - text="oosvar_keylist", type=OOSVAR_KEYLIST: - text="c", type=STRING_LITERAL. - text="3", type=NUMERIC_LITERAL. - local1 = 1 local3 = -a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533 -a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797 -a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776 -a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463 -a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729 -a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697 -a=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694 -a=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006 -a=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059 -a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864 local2 = 2 local4 = -a=10 -b=20 -c=30 +a b i x y +pan pan 1 0.3467901443380824 0.7268028627434533 +eks pan 2 0.7586799647899636 0.5221511083334797 +wye wye 3 0.20460330576630303 0.33831852551664776 +eks wye 4 0.38139939387114097 0.13418874328430463 +wye pan 5 0.5732889198020006 0.8636244699032729 +zee pan 6 0.5271261600918548 0.49322128674835697 +eks zee 7 0.6117840605678454 0.1878849191181694 +zee wye 8 0.5985540091064224 0.976181385699006 +hat wye 9 0.03144187646093577 0.7495507603507059 +pan wye 10 0.5026260055412137 0.9526183602969864 mlr --from ./reg-test/input/abixy --opprint put subr log(text) { print "TEXT IS ".text } call log("NR is ".NR) TEXT IS NR is 1 @@ -622,61 +287,60 @@ zee wye 8 0.5985540091064224 0.976181385699006 zeezee hat wye 9 0.03144187646093577 0.7495507603507059 hathat pan wye 10 0.5026260055412137 0.9526183602969864 panpan -mlr --from ./reg-test/input/abixy put begin{@x=1} func f(x) { dump; print "hello" } $o=f($i) +mlr --from ./reg-test/input/abixy --opprint put begin{@x=1} func f(x) { dump; print "hello" } $o=f($i) { "x": 1 } hello -a=pan,b=pan,i=1,x=0.3467901443380824,y=0.7268028627434533 { "x": 1 } hello -a=eks,b=pan,i=2,x=0.7586799647899636,y=0.5221511083334797 { "x": 1 } hello -a=wye,b=wye,i=3,x=0.20460330576630303,y=0.33831852551664776 { "x": 1 } hello -a=eks,b=wye,i=4,x=0.38139939387114097,y=0.13418874328430463 { "x": 1 } hello -a=wye,b=pan,i=5,x=0.5732889198020006,y=0.8636244699032729 { "x": 1 } hello -a=zee,b=pan,i=6,x=0.5271261600918548,y=0.49322128674835697 { "x": 1 } hello -a=eks,b=zee,i=7,x=0.6117840605678454,y=0.1878849191181694 { "x": 1 } hello -a=zee,b=wye,i=8,x=0.5985540091064224,y=0.976181385699006 { "x": 1 } hello -a=hat,b=wye,i=9,x=0.03144187646093577,y=0.7495507603507059 { "x": 1 } hello -a=pan,b=wye,i=10,x=0.5026260055412137,y=0.9526183602969864 +a b i x y +pan pan 1 0.3467901443380824 0.7268028627434533 +eks pan 2 0.7586799647899636 0.5221511083334797 +wye wye 3 0.20460330576630303 0.33831852551664776 +eks wye 4 0.38139939387114097 0.13418874328430463 +wye pan 5 0.5732889198020006 0.8636244699032729 +zee pan 6 0.5271261600918548 0.49322128674835697 +eks zee 7 0.6117840605678454 0.1878849191181694 +zee wye 8 0.5985540091064224 0.976181385699006 +hat wye 9 0.03144187646093577 0.7495507603507059 +pan wye 10 0.5026260055412137 0.9526183602969864 mlr --from ./reg-test/input/abixy put begin{@x=1} func f(x) { dump; print "hello"; tee > "x", $* } $o=f($i) -mlr: tee statements are not valid within func blocks. mlr --from ./reg-test/input/abixy put begin{@x=1} func f(x) { dump; print "hello"; emit > "x", @* } $o=f($i) -mlr: emit statements are not valid within func blocks.