Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add jaq support #20

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

Add jaq support #20

wants to merge 14 commits into from

Conversation

wader
Copy link
Owner

@wader wader commented Nov 5, 2024

Useful snippets and references:

jaq -L . -n 'include "jqjq"; _builtins_src | lex'
jaq -n -L . -rRs 'include "jqjq"; . | jqjq(["", "--run-tests"]; {})' < jqjq.test
jaq -n -L . 'include "jqjq"; eval("1+2")'

Disable TCO 01mf02/jaq#223 (comment)

jaq add jqjq support issue 01mf02/jaq#216

@wader wader marked this pull request as draft November 5, 2024 12:28
@wader wader mentioned this pull request Nov 5, 2024
@wader
Copy link
Owner Author

wader commented Nov 5, 2024

Current progress:

$ jaq -n -L . -rRs 'include "jqjq"; . | jqjq(["", "--run-tests"]; {})' < jqjq.test | grep -v OK:
ERROR: line 14: null | 123, 1.23, 0.123, .123, .123e1, 1.23e1, 2E3, 1.23e+1, 1.23E-2 -> 123,1.23,0.123,0.123,1.23,12.3,2000,12.3,0.0123
  cannot parse .123 as JSON: value expected
ERROR: line 40: "b" | "aaa \("a" + . + "c") ccc" -> "aaa abc ccc"
  cannot use null as iterable (array or object)
ERROR: line 52: null | "aaa \(1,2,3) bbb" -> "aaa 1 bbb","aaa 2 bbb","aaa 3 bbb"
  cannot use null as iterable (array or object)
ERROR: line 95: "abcäሴ💩" | @uri "aaa \(.) bbb \(.)" -> "aaa abc%C3%A4%E1%88%B4%F0%9F%92%A9 bbb abc%C3%A4%E1%88%B4%F0%9F%92%A9"
  cannot calculate 195.0 % 16
ERROR: line 131: {"a":1} | {a} -> {"a":1}
  cannot use null as iterable (array or object)
ERROR: line 135: {"a":1} | {"a"} -> {"a":1}
  cannot use null as iterable (array or object)
ERROR: line 139: null | 1 as $a | {$a} -> {"a":1}
  cannot use null as iterable (array or object)
ERROR: line 147: null | {a: 1, b: 2} | 3 as $c | {a, "b", $c, ("d"): 4} -> {"a":1,"b":2,"c":3,"d":4}
  cannot use null as iterable (array or object)
ERROR: line 489: {"a":1,"b":2} | del(.a) -> {"b":2}
  undefined function delpaths/1
ERROR: line 493: [1,2,3] | del(.[1]) -> [1,3]
  undefined function delpaths/1
ERROR: line 497: [1,2,3] | del(.[1],.[1]) -> [1,3]
  undefined function delpaths/1
ERROR: line 527: null | .a = 123 -> {"a":123}
  cannot use null as iterable (array or object)
ERROR: line 531: null | (.a,.b) = 123 -> {"a":123,"b":123}
  cannot use null as iterable (array or object)
ERROR: line 536: null | .a = 123 | .a |= . + 1 -> {"a":124}
  cannot use null as iterable (array or object)
ERROR: line 540: null | .a = 123 | (.a,.b) |= . + 3 -> {"a":126,"b":3}
  cannot use null as iterable (array or object)
ERROR: line 546: null | .a = 123 | .a += 3 -> {"a":126}
  cannot use null as iterable (array or object)
ERROR: line 550: null | .a = 123 | (.a,.b) += 3 -> {"a":126,"b":3}
  cannot use null as iterable (array or object)
ERROR: line 555: null | .a = 3 | .a += .a + 3 -> {"a":9}
  cannot use null as iterable (array or object)
ERROR: line 561: null | .a = 123 | .a -= 3 -> {"a":120}
  cannot use null as iterable (array or object)
ERROR: line 565: null | .a = 123 | .b = 0 | (.a,.b) -= 3 -> {"a":120,"b":-3}
  cannot use null as iterable (array or object)
ERROR: line 571: null | .a = 123 | .a *= 3 -> {"a":369}
  cannot use null as iterable (array or object)
ERROR: line 575: null | .a = 123 | .b = 1 | (.a,.b) *= 3 -> {"a":369,"b":3}
  cannot use null as iterable (array or object)
ERROR: line 581: null | .a = 120 | .a /= 3 -> {"a":40}
  cannot use null as iterable (array or object)
ERROR: line 585: null | .a = 120 | .b = 3 | (.a,.b) /= 3 -> {"a":40,"b":1}
  cannot use null as iterable (array or object)
ERROR: line 591: null | .a = 123 | .a %= 4 -> {"a":3}
  cannot use null as iterable (array or object)
ERROR: line 595: null | .a = 123 | .b = 4 | (.a,.b) %= 4 -> {"a":3,"b":0}
  cannot use null as iterable (array or object)
DIFF: line 697: null | try (1+"a") catch . -> "number (1) and string (\"a\") cannot be added"
  Expected: "number (1) and string (\"a\") cannot be added"
    Actual: "cannot calculate 1 + \"a\""
DIFF: line 707: null | error(123)? // 456 -> 456
  Expected: 456
    Actual: 
ERROR: line 811: [[],[{"a":1}],[{"a":1},{"a":2},{"a":1}]] | map(group_by(.a)) -> [[],[[{"a":1}]],[[{"a":1},{"a":1}],[{"a":2}]]]
  undefined function setpath/2
ERROR: line 815: [{"a":1,"b":2},{"a":2},{"a":1,"b":2}] | group_by(.a, .b) -> [[{"a":1,"b":2},{"a":1,"b":2}],[{"a":2}]]
  undefined function setpath/2
ERROR: line 819: [[],[{"a":1}],[{"a":1},{"a":2},{"a":1}]] | map(group_by(.a)) -> [[],[[{"a":1}]],[[{"a":1},{"a":1}],[{"a":2}]]]
  undefined function setpath/2
ERROR: line 823: [{"a":1,"b":2},{"a":2},{"a":1,"b":2}] | unique_by(.a, .b) -> [{"a":1,"b":2},{"a":2}]
  undefined function setpath/2
ERROR: line 827: [[],[1],[3,2,2],[3,1,1,2]] | map(unique) -> [[],[1],[2,3],[1,2,3]]
  undefined function setpath/2
ERROR: line 863: [{"key":"a","value":1},{"Key":"b","Value":2},{"Name":"c","value":false}] | from_entries -> {"a":1,"b":2,"c":false}
  undefined function setpath/2
ERROR: line 867: {"a":1,"b":2} | with_entries(.key |= "_"+. | .value += 100) -> {"_a":101,"_b":102}
  undefined function setpath/2
ERROR: line 968: {"a":{"c":1},"b":{"c":2}} | .[].c = 123 -> {"a":{"c":123},"b":{"c":123}}
  undefined function setpath/2
ERROR: line 983: [[1,2],[3,4]] | .[][] += 1 -> [[2,3],[4,5]]
  undefined function setpath/2
DIFF: line 998: null | empty // empty // 123 -> 123
  Expected: 123
    Actual: 
DIFF: line 1002: null | . // . // 123 -> 123
  Expected: 123
    Actual: 
DIFF: line 1006: null | (1,null,2,3) // 123 -> 1,2,3
  Expected: 1,2,3
    Actual: 1
DIFF: line 1012: null | null // (1,null,2,3) -> 1,null,2,3
  Expected: 1,null,2,3
    Actual: 
DIFF: line 1019: null | null // 1,2 // 123 -> 1,2
  Expected: 1,2
    Actual: 2
DIFF: line 1029: null | try (empty // 1,error("a"),2) catch . -> 1,"a"
  Expected: 1,"a"
    Actual: "a"
ERROR: line 1035: {"foo":0} | (.foo,.foo,.foo) |= .+1 -> {"foo":3}
  undefined function setpath/2
ERROR: line 1078: [1,2,3] | bsearch(0,2,4) -> -1,1,-4
  undefined function setpath/2
ERROR: line 1159: {} | [path(.a, .b.c)] -> [["a"],["b","c"]]
  cannot use null as iterable (array or object)
ERROR: line 1183: [[],[1],[3,2,2],[3,1,1,2]] | map(group) -> [[],[[1]],[[2,2],[3]],[[1,1],[2],[3]]]
  undefined function setpath/2
ERROR: line 1238: null | (.a | eval(".a, .b.c")) = 123 -> {"a":{"a":123,"b":{"c":123}}}
  cannot use null as iterable (array or object)
205 of 253 tests passed
null

Useful snippets and references:

jaq -L . -n 'include "jqjq"; _builtins_src | lex'
jaq -n -L . -rRs 'include "jqjq"; . | jqjq(["", "--run-tests"]; {})' < jqjq.test
jaq -n -L . 'include "jqjq"; eval("1+2")'
Disable TCO 01mf02/jaq#223 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant