patmok / unparse

unparse parse tree for kdb+/q
17 stars 2 forks source link

Does not handle ([]...) table creation #6

Closed semitrivial closed 8 years ago

semitrivial commented 8 years ago

.unparse.unparse parse "([]c:1 2 3)"

returns the incorrect

"flip (x!enlist[1 2 3])"`

patmok commented 8 years ago

hmmm which commit are you using?

i can't seem to replicate it

patrick@ubuntu:~/git/unparse$ git checkout master Already on 'master' Your branch is up-to-date with 'origin/master'. patrick@ubuntu:~/git/unparse$ git pull Already up-to-date. patrick@ubuntu:~/git/unparse$ q unparse.q KDB+ 3.4t 2016.01.31 Copyright (C) 1993-2016 Kx Systems l32/ 1()core 489MB patrick ubuntu 127.0.1.1 NONEXPIRE

q).unparse.unparse parse "([]c:1 2 3)" "flip (`c!enlist[1 2 3])"

EDIT: ah i see, enlist is missing

patmok commented 8 years ago

this is tricky to fix, the syntactic sugar doesn't really follow the parse tree convention:

q)parse "([]c:1 2 3)" +: (!;,,c;(enlist;1 2 3)) q)ideal:(+:;(!;(enlist;enlistc);(enlist;1 2 3))) q).unparse.unparse ideal "flip (enlist[`c]!enlist[1 2 3])"

looks like only table creation short hand can generate the ,,`c ?

q)p:parse "([]c:1 2 3)" q)enlist[enlist`c]~{x 1}last p 1b

,,`c is somewhat "flattened", will require special case to handle this, hmmm

semitrivial commented 8 years ago

Right, it has special parse treatment because, like the columns in a select, the column names are entered raw instead of via a variable.

patmok commented 8 years ago

fixed, thanks for reporting this