grol-io / grol

Go REPL Open Language
https://grol.io
Apache License 2.0
13 stars 1 forks source link

parsing issue/weirdness with literal arrays in if #188

Closed ldemailly closed 2 weeks ago

ldemailly commented 2 weeks ago
if true{log("x")[i,j]}
14:53:22.838 [ERR] parser error: 1: expected next token to be `]`, got `,` instead:
if true{log("x")[i,j]}
                  ^
14:53:22.838 [ERR] parser error: 1: no prefix parse function for `,` found:
if true{log("x")[i,j]}
                  ^
14:53:22.838 [ERR] parser error: 1: no prefix parse function for `]` found:
if true{log("x")[i,j]}
                    ^
()=>if true{log("x");[i,j]} //parses fine with ; but then generates the above which doesn't parse back
()=>if true{log("x")[i,j]}

probably because of index operator

ldemailly commented 2 weeks ago

also

a [0]

ie [] should be like () stuck to the left for it to be index and not array literal

ldemailly commented 2 weeks ago

the parsing is ok but the space is missing

$ ()=>if true{log("x");[i,j]}
== Parse ==> ()=>{if true{log("x") [i,j]}}
== Eval  ==> ()=>if true{log("x") [i,j]}

fixing in #191