Conversation
|
Wow! nice. Will have a look later, i'm a bit out and about So there was no issue with "end" being parsed as a function? There are no strict rules really about intrinsic or anything, but i have tried to reimplement instead of "passthru" as much as possible when "resonable"... not that resonable makes any sense for this projects 😬 |
|
Also feel free to add some test to jqjq.test. |
|
If not too much of hack to run maybe can add something to README.md also? |
|
About I can add tests. I'd rather not link to wsjq from here and say it's officially supported, until there's a better experience running wsjq. Particularly, supporting the flags for raw input and raw output would make a big difference. I could work around |
|
FYI, two already-existing tests fail for both jqjq and jq. jqjq uses |
You mean there are jqjq.test using For
Should be fixed by 157add8 |
👍
👍
No worries, sounds good.
Ideally i think jqjq should always do raw input/output and take care of json parsing encoding itself. but i guess there are some e tricky things like support reading multiple json values. need to have fromjson variant that can return "rest" etc?
I've kind of out of idea how
Yeap it seems a bit tricky to do. If i remember correctly the lexer probably have to become quite a bit more complicated and keep some state around? but maybe there are better ways of doing it. I'll think about it. Let's see how it goes, work on jqjq is very curiosity/motivational-driven 😄 |
jqjq.jq
Outdated
| def capture($val): ($val|type) as $vt | if $vt == \"string\" then capture($val; null) | ||
| elif $vt == \"array\" and ($val | length) > 1 then capture($val[0]; $val[1]) | ||
| elif $vt == \"array\" and ($val | length) > 0 then capture($val[0]; null) | ||
| else error( $vt + \" not a string or array\") end; |
There was a problem hiding this comment.
Would be nice to make the non-trivial-functions look more like the rest of jqjq
def match($val):
( ($val | type) as $vt
| if $vt == "string" then match($val; null)
elif $vt == "array" and ($val | length) > 1 then match($val[0]; $val[1])
# ...
);There was a problem hiding this comment.
I've reformatted the new builtins. I'm unsure about capture/2, since that's the only occurrence in jqjq with a reduce with a complex as-binding.
|
Looks good! just had some minor comments |
c5885ef to
0e4b170
Compare
|
LGTM, merge? |
0e4b170 to
a86c036
Compare
f2f0b70 to
f730068
Compare
|
btw i sometimes run |
|
I wrote a better runner, In the wsjqjq runner, I figured out a workaround, where the output is piped to another jq instance, which strips the JSON syntax with |
|
I figure a better CLI, that allows forwarding flags like I noted wsjq support in your README and mine, since the rough edges have been smoothed over by patches here and hacks on my end for what's left. I'd say we're good to merge! |
|
Nice work! 🥳 the "Manually resolve imports." is quite a hack 😄 Yeap let's merge this and we can continue in new PRs to smooth things even more Big thanks! |
|
Just a few more builtins should get you to 99%, … and a more fleshed out CLI would set you back haha |
|
Yeap is hard balance! :) |

This makes the minimal changes needed to run wsjq, at least with count.ws. To test it with wsjq, check out my jqjq-compat branch and run
test_jqjq.sh.I added an intrinsic for
test/2, copied the builtins forindices/1,index/1,rindex/1,match/1,test/1,capture/2, andcapture/1from builtin.jq, and reimplemented the_strindicesintrinsic as a jq builtin.I'm not entirely certain what your metric is for your separation between adding a builtin to
_builtins_srcor to the match over the filter signature. It seems like you prefer deferring to jq for numeric filters and adding most others as builtins, while some liketo-/fromjsonhave their own definitions._builtins_srcdoesn't match the source ofbuiltin.jqand appears to be manually edited. Any of the builtins I added would certainly be faster as intrinsics deferring to jq's implementations, but I put them in builtins to follow what looks like your pattern.Let me know if you'd like any changes.