

================================================================
OOSVAR-FROM-SREC ASSIGNMENT

mlr put -v @v     = $* /dev/null
DSL EXPRESSION:
@v     = $*

AST:
* statement block
    * assignment "="
        * direct oosvar value "v"
        * full record "$*"


mlr put -v @v[1]  = $* /dev/null
DSL EXPRESSION:
@v[1]  = $*

AST:
* statement block
    * assignment "="
        * array or map index access "[]"
            * direct oosvar value "v"
            * int literal "1"
        * full record "$*"


mlr put -v @v[$2] = $* /dev/null
DSL EXPRESSION:
@v[$2] = $*

AST:
* statement block
    * assignment "="
        * array or map index access "[]"
            * direct oosvar value "v"
            * direct field value "2"
        * full record "$*"


mlr put -v NR == 3 {@v     = $*} /dev/null
DSL EXPRESSION:
NR == 3 {@v     = $*}

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * direct oosvar value "v"
                * full record "$*"


mlr put -v NR == 3 {@v[1]  = $*} /dev/null
DSL EXPRESSION:
NR == 3 {@v[1]  = $*}

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"
                * full record "$*"


mlr put -v NR == 3 {@v[$2] = $*} /dev/null
DSL EXPRESSION:
NR == 3 {@v[$2] = $*}

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * direct field value "2"
                * full record "$*"


mlr --oxtab put -q @v = $*; end {emitp @v } ./reg-test/input/abixy-het
v.a pan
v.b wye
v.i 10
v.x 0.5026260055412137
v.y 0.9526183602969864

mlr --oxtab put -q @v[$a] = $*; end {emitp @v      } ./reg-test/input/abixy-het
v.pan.a   pan
v.pan.b   wye
v.pan.i   10
v.pan.x   0.5026260055412137
v.pan.y   0.9526183602969864
v.eks.a   eks
v.eks.b   zee
v.eks.iii 7
v.eks.x   0.6117840605678454
v.eks.y   0.1878849191181694
v.wye.a   wye
v.wye.b   pan
v.wye.i   5
v.wye.xxx 0.5732889198020006
v.wye.y   0.8636244699032729
v.zee.a   zee
v.zee.b   wye
v.zee.i   8
v.zee.x   0.5985540091064224
v.zee.yyy 0.976181385699006

mlr --oxtab put -q @v[$a] = $*; end {emitp @v, "a" } ./reg-test/input/abixy-het
a   pan
v.a pan
v.b wye
v.i 10
v.x 0.5026260055412137
v.y 0.9526183602969864

a     eks
v.a   eks
v.b   zee
v.iii 7
v.x   0.6117840605678454
v.y   0.1878849191181694

a     wye
v.a   wye
v.b   pan
v.i   5
v.xxx 0.5732889198020006
v.y   0.8636244699032729

a     zee
v.a   zee
v.b   wye
v.i   8
v.x   0.5985540091064224
v.yyy 0.976181385699006

mlr --oxtab put -q @v[$a][$b] = $*; end {emitp @v          } ./reg-test/input/abixy-het
v.pan.pan.a   pan
v.pan.pan.b   pan
v.pan.pan.i   1
v.pan.pan.x   0.3467901443380824
v.pan.pan.y   0.7268028627434533
v.pan.wye.a   pan
v.pan.wye.b   wye
v.pan.wye.i   10
v.pan.wye.x   0.5026260055412137
v.pan.wye.y   0.9526183602969864
v.eks.pan.a   eks
v.eks.pan.b   pan
v.eks.pan.i   2
v.eks.pan.x   0.7586799647899636
v.eks.pan.y   0.5221511083334797
v.eks.zee.a   eks
v.eks.zee.b   zee
v.eks.zee.iii 7
v.eks.zee.x   0.6117840605678454
v.eks.zee.y   0.1878849191181694
v.wye.pan.a   wye
v.wye.pan.b   pan
v.wye.pan.i   5
v.wye.pan.xxx 0.5732889198020006
v.wye.pan.y   0.8636244699032729
v.zee.pan.a   zee
v.zee.pan.b   pan
v.zee.pan.i   6
v.zee.pan.x   0.5271261600918548
v.zee.pan.y   0.49322128674835697
v.zee.wye.a   zee
v.zee.wye.b   wye
v.zee.wye.i   8
v.zee.wye.x   0.5985540091064224
v.zee.wye.yyy 0.976181385699006

mlr --oxtab put -q @v[$a][$b] = $*; end {emitp @v, "a"     } ./reg-test/input/abixy-het
a       pan
v.pan.a pan
v.pan.b pan
v.pan.i 1
v.pan.x 0.3467901443380824
v.pan.y 0.7268028627434533
v.wye.a pan
v.wye.b wye
v.wye.i 10
v.wye.x 0.5026260055412137
v.wye.y 0.9526183602969864

a         eks
v.pan.a   eks
v.pan.b   pan
v.pan.i   2
v.pan.x   0.7586799647899636
v.pan.y   0.5221511083334797
v.zee.a   eks
v.zee.b   zee
v.zee.iii 7
v.zee.x   0.6117840605678454
v.zee.y   0.1878849191181694

a         wye
v.pan.a   wye
v.pan.b   pan
v.pan.i   5
v.pan.xxx 0.5732889198020006
v.pan.y   0.8636244699032729

a         zee
v.pan.a   zee
v.pan.b   pan
v.pan.i   6
v.pan.x   0.5271261600918548
v.pan.y   0.49322128674835697
v.wye.a   zee
v.wye.b   wye
v.wye.i   8
v.wye.x   0.5985540091064224
v.wye.yyy 0.976181385699006

mlr --oxtab put -q @v[$a][$b] = $*; end {emitp @v, "a", "b"} ./reg-test/input/abixy-het
a   pan
b   pan
v.a pan
v.b pan
v.i 1
v.x 0.3467901443380824
v.y 0.7268028627434533

a   pan
b   wye
v.a pan
v.b wye
v.i 10
v.x 0.5026260055412137
v.y 0.9526183602969864

a   eks
b   pan
v.a eks
v.b pan
v.i 2
v.x 0.7586799647899636
v.y 0.5221511083334797

a     eks
b     zee
v.a   eks
v.b   zee
v.iii 7
v.x   0.6117840605678454
v.y   0.1878849191181694

a     wye
b     pan
v.a   wye
v.b   pan
v.i   5
v.xxx 0.5732889198020006
v.y   0.8636244699032729

a   zee
b   pan
v.a zee
v.b pan
v.i 6
v.x 0.5271261600918548
v.y 0.49322128674835697

a     zee
b     wye
v.a   zee
v.b   wye
v.i   8
v.x   0.5985540091064224
v.yyy 0.976181385699006


================================================================
SREC-FROM-OOSVAR ASSIGNMENT

mlr put -v $* = @v     /dev/null
DSL EXPRESSION:
$* = @v    

AST:
* statement block
    * assignment "="
        * full record "$*"
        * direct oosvar value "v"


mlr put -v $* = @v[1]  /dev/null
DSL EXPRESSION:
$* = @v[1] 

AST:
* statement block
    * assignment "="
        * full record "$*"
        * array or map index access "[]"
            * direct oosvar value "v"
            * int literal "1"


mlr put -v $* = @v[$2] /dev/null
DSL EXPRESSION:
$* = @v[$2]

AST:
* statement block
    * assignment "="
        * full record "$*"
        * array or map index access "[]"
            * direct oosvar value "v"
            * direct field value "2"


mlr put -v NR == 3 {$* = @v    } /dev/null
DSL EXPRESSION:
NR == 3 {$* = @v    }

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * full record "$*"
                * direct oosvar value "v"


mlr put -v NR == 3 {$* = @v[1] } /dev/null
DSL EXPRESSION:
NR == 3 {$* = @v[1] }

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * full record "$*"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"


mlr put -v NR == 3 {$* = @v[$2]} /dev/null
DSL EXPRESSION:
NR == 3 {$* = @v[$2]}

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * full record "$*"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * direct field value "2"


mlr put @v[NR] = $a; NR == 7 { @v = $*} ; $* = @v ./reg-test/input/abixy-het
1=pan
1=pan,2=eks
1=pan,2=eks
1=pan,2=eks,4=eks
1=pan,2=eks,4=eks,5=wye
1=pan,2=eks,4=eks,5=wye,6=zee
a=eks,b=zee,iii=7,x=0.6117840605678454,y=0.1878849191181694
a=eks,b=zee,iii=7,x=0.6117840605678454,y=0.1878849191181694,8=zee
a=eks,b=zee,iii=7,x=0.6117840605678454,y=0.1878849191181694,8=zee
a=eks,b=zee,iii=7,x=0.6117840605678454,y=0.1878849191181694,8=zee,10=pan


================================================================
OOSVAR-FROM-OOSVAR ASSIGNMENT

mlr put -v @u    = @v /dev/null
DSL EXPRESSION:
@u    = @v

AST:
* statement block
    * assignment "="
        * direct oosvar value "u"
        * direct oosvar value "v"


mlr put -v @u    = @v[1] /dev/null
DSL EXPRESSION:
@u    = @v[1]

AST:
* statement block
    * assignment "="
        * direct oosvar value "u"
        * array or map index access "[]"
            * direct oosvar value "v"
            * int literal "1"


mlr put -v @u[2] = @v /dev/null
DSL EXPRESSION:
@u[2] = @v

AST:
* statement block
    * assignment "="
        * array or map index access "[]"
            * direct oosvar value "u"
            * int literal "2"
        * direct oosvar value "v"


mlr put -v @u[2] = @v[1] /dev/null
DSL EXPRESSION:
@u[2] = @v[1]

AST:
* statement block
    * assignment "="
        * array or map index access "[]"
            * direct oosvar value "u"
            * int literal "2"
        * array or map index access "[]"
            * direct oosvar value "v"
            * int literal "1"


mlr put -v begin { @u    = @v } /dev/null
DSL EXPRESSION:
begin { @u    = @v }

AST:
* statement block
    * begin block
        * statement block
            * assignment "="
                * direct oosvar value "u"
                * direct oosvar value "v"


mlr put -v begin { @u    = @v[1] } /dev/null
DSL EXPRESSION:
begin { @u    = @v[1] }

AST:
* statement block
    * begin block
        * statement block
            * assignment "="
                * direct oosvar value "u"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"


mlr put -v begin { @u[2] = @v } /dev/null
DSL EXPRESSION:
begin { @u[2] = @v }

AST:
* statement block
    * begin block
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "u"
                    * int literal "2"
                * direct oosvar value "v"


mlr put -v begin { @u[2] = @v[1] } /dev/null
DSL EXPRESSION:
begin { @u[2] = @v[1] }

AST:
* statement block
    * begin block
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "u"
                    * int literal "2"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"


mlr put -v NR == 3 { @u    = @v } /dev/null
DSL EXPRESSION:
NR == 3 { @u    = @v }

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * direct oosvar value "u"
                * direct oosvar value "v"


mlr put -v NR == 3 { @u    = @v[1] } /dev/null
DSL EXPRESSION:
NR == 3 { @u    = @v[1] }

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * direct oosvar value "u"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"


mlr put -v NR == 3 { @u[2] = @v } /dev/null
DSL EXPRESSION:
NR == 3 { @u[2] = @v }

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "u"
                    * int literal "2"
                * direct oosvar value "v"


mlr put -v NR == 3 { @u[2] = @v[1] } /dev/null
DSL EXPRESSION:
NR == 3 { @u[2] = @v[1] }

AST:
* statement block
    * cond block
        * operator "=="
            * context variable "NR"
            * int literal "3"
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "u"
                    * int literal "2"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"


mlr put -v end { @u    = @v } /dev/null
DSL EXPRESSION:
end { @u    = @v }

AST:
* statement block
    * end block
        * statement block
            * assignment "="
                * direct oosvar value "u"
                * direct oosvar value "v"


mlr put -v end { @u    = @v[1] } /dev/null
DSL EXPRESSION:
end { @u    = @v[1] }

AST:
* statement block
    * end block
        * statement block
            * assignment "="
                * direct oosvar value "u"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"


mlr put -v end { @u[2] = @v } /dev/null
DSL EXPRESSION:
end { @u[2] = @v }

AST:
* statement block
    * end block
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "u"
                    * int literal "2"
                * direct oosvar value "v"


mlr put -v end { @u[2] = @v[1] } /dev/null
DSL EXPRESSION:
end { @u[2] = @v[1] }

AST:
* statement block
    * end block
        * statement block
            * assignment "="
                * array or map index access "[]"
                    * direct oosvar value "u"
                    * int literal "2"
                * array or map index access "[]"
                    * direct oosvar value "v"
                    * int literal "1"


mlr put -q @s    += $i; @t=@s;             end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": 55,
  "t": 55
}
s=55
t=55

mlr put -q @s[1] += $i; @t=@s;             end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": 55
  },
  "t": {
    "1": 55
  }
}
s.1=55
t.1=55

mlr put -q @s[1] += $i; @t=@s[1];          end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": 55
  },
  "t": 55
}
s.1=55
t=55

mlr put -q @s[1] += $i; @t[3]=@s;          end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": 55
  },
  "t": {
    "3": {
      "1": 55
    }
  }
}
s.1=55
t.3.1=55

mlr put -q @s[1] += $i; @t[3]=@s[1];       end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": 55
  },
  "t": {
    "3": 55
  }
}
s.1=55
t.3=55

mlr put -q @s[1][2] += $i; @t=@s;             end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "1": {
      "2": 55
    }
  }
}
s.1.2=55
t.1.2=55

mlr put -q @s[1][2] += $i; @t=@s[1];          end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "2": 55
  }
}
s.1.2=55
t.2=55

mlr put -q @s[1][2] += $i; @t=@s[1][2];       end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": 55
}
s.1.2=55
t=55

mlr put -q @s[1][2] += $i; @t[3]=@s;          end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "3": {
      "1": {
        "2": 55
      }
    }
  }
}
s.1.2=55
t.3.1.2=55

mlr put -q @s[1][2] += $i; @t[3]=@s[1];       end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "3": {
      "2": 55
    }
  }
}
s.1.2=55
t.3.2=55

mlr put -q @s[1][2] += $i; @t[3]=@s[1][2];    end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "3": 55
  }
}
s.1.2=55
t.3=55

mlr put -q @s[1][2] += $i; @t[3][4]=@s;       end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "3": {
      "4": {
        "1": {
          "2": 55
        }
      }
    }
  }
}
s.1.2=55
t.3.4.1.2=55

mlr put -q @s[1][2] += $i; @t[3][4]=@s[1];    end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "3": {
      "4": {
        "2": 55
      }
    }
  }
}
s.1.2=55
t.3.4.2=55

mlr put -q @s[1][2] += $i; @t[3][4]=@s[1][2]; end{dump; emitp@s; emitp @t} ./reg-test/input/abixy
{
  "s": {
    "1": {
      "2": 55
    }
  },
  "t": {
    "3": {
      "4": 55
    }
  }
}
s.1.2=55
t.3.4=55

mlr --opprint put -q @s[NR][NR] = $i/100; @t[NR*10]=@s; end{emitp@s,"A","B"; emitp @t,"C","D","E"} ./reg-test/input/abixy
A  B  s
1  1  0.01
2  2  0.02
3  3  0.03
4  4  0.04
5  5  0.05
6  6  0.06
7  7  0.07
8  8  0.08
9  9  0.09
10 10 0.1

C   D  E  t
10  1  1  0.01
20  1  1  0.01
20  2  2  0.02
30  1  1  0.01
30  2  2  0.02
30  3  3  0.03
40  1  1  0.01
40  2  2  0.02
40  3  3  0.03
40  4  4  0.04
50  1  1  0.01
50  2  2  0.02
50  3  3  0.03
50  4  4  0.04
50  5  5  0.05
60  1  1  0.01
60  2  2  0.02
60  3  3  0.03
60  4  4  0.04
60  5  5  0.05
60  6  6  0.06
70  1  1  0.01
70  2  2  0.02
70  3  3  0.03
70  4  4  0.04
70  5  5  0.05
70  6  6  0.06
70  7  7  0.07
80  1  1  0.01
80  2  2  0.02
80  3  3  0.03
80  4  4  0.04
80  5  5  0.05
80  6  6  0.06
80  7  7  0.07
80  8  8  0.08
90  1  1  0.01
90  2  2  0.02
90  3  3  0.03
90  4  4  0.04
90  5  5  0.05
90  6  6  0.06
90  7  7  0.07
90  8  8  0.08
90  9  9  0.09
100 1  1  0.01
100 2  2  0.02
100 3  3  0.03
100 4  4  0.04
100 5  5  0.05
100 6  6  0.06
100 7  7  0.07
100 8  8  0.08
100 9  9  0.09
100 10 10 0.1

