1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

25 Commits

Author SHA1 Message Date
ae7f8d6ab9 Further module system revamp (fix #659)
To import a module now use:

    # Import module.jq file:
    import "relative/path/to/module" as foo;

    # Use the module's defs as foo::<def-name>

To import a JSON file:

    # Read file.json:
    import "relative/path/to/file" as $foo;
    #
    # Use as $foo::foo

Using `-L` now drops the builtin library path and appends the requested
path to the empty array (or the result of an earlier `-L`).

Support for the `$JQ_LIBRARY_PATH` environment variable has been
removed.
2014-12-31 20:09:53 -06:00
7dc34b92af Add label $name | EXP; fix break
This is to fix the problem where `break` is dynamic, not lexical.

With this it should be possible to do this sort of thing:

    label $break | inputs | if ... then $break|error else . end

This is a backwards-incompatible change for master, but the previous
`break` hadn't shipped yet.

Still needed:

 - testing
2014-12-30 11:42:45 -06:00
7243989c52 Fix refcount leak, fix #618 2014-11-29 15:24:43 -06:00
1ba8c2cfa6 Add module directive, modulemeta builtin
Fix #425.
2014-08-14 03:26:26 -05:00
32c08d48f3 Add def f($arg): syntax (fix #524) 2014-08-08 19:16:01 -05:00
38b939688a Added library system with -l, -L, and JQ_LIBRARY_PATH
Created util.[ch] to hold common utilities.
2014-07-22 22:51:11 -05:00
8780bc0b8e Better check for lib has only functions (fix #138) 2014-07-07 16:03:32 -05:00
7fce34292e Add try EXP catch EXP 2014-07-06 01:29:42 -05:00
436941d48b TCO to the max!
Close #446.

    Currently tested by disassembling and tracing various recursive jq
    programs by hand under valgrind.  An improved test framework that
    can test for errors and specific bytecode patterns is in
    development.
2014-06-30 23:41:20 -05:00
fe29d3d3fa Add ?, .[]?, and .. operators
Make XPath-like `//a/b` recursive structure traversal easier in jq,
which then becomes:

    ..|.a?.b?

The `?` operator suppresses errors about . not being an array or object.
The `..` operator is equivalent to calling the new `recurse_down`
built-in, which in turn is equivalent to

    recurse(.[]?)

Note that `..a` is not supported; neither is `...a`.  That could be add
added, but it doesn't seem worth the trouble of saving the need to type
a '|'.
2014-02-20 15:33:07 -06:00
8fbee891b3 Add LOADVN opcode.
Does a variable load, but sets the variable to be null afterwards.
2013-05-16 15:02:18 +01:00
1e2851cdb3 Remove the YIELD opcode (use RET instead) 2013-05-15 01:23:06 +01:00
81be37b236 Add the range function 2013-05-14 16:09:10 +01:00
8c708f3c7a Refactor path logic. 2013-05-13 15:00:05 +01:00
c013b557a2 Change APPEND opcode to directly modify a variable.
Avoids a big O(n^2) loop in constructing arrays. Fixes #61.
2013-01-03 12:51:33 +00:00
d5fdf70434 Refactor assignment.
New version is much more elegant and probably slower. Uses
library functions implemented in jq rather than dedicated opcodes.
2012-12-29 16:43:36 +00:00
79c9c418c6 Path manipulation (path/getpath/setpath/delpath) and docs.
del function should fix #37.
2012-12-28 16:08:29 +00:00
616e8f9924 Refactor function argument passing into what it always should have been.
Most visible change is that error messages when a function is called
with the wrong number of arguments are much better.
2012-12-04 00:39:21 +00:00
a88d53d2fd Extend {foo} syntax to allow {"foo"} as well.
Useful when "foo" contains unusual characters. Should help with
the issues #7, #38, #40, #42.
2012-12-03 20:31:40 +00:00
5f6a95c7b5 General cleanup - rename a few things, delete dead code. 2012-12-03 20:02:02 +00:00
125e278502 Clean up calls to C functions, unify opcodes 2012-12-02 20:45:55 +00:00
251f221b85 Refactor of function call codegen. Separate codegen for C and jq calls. 2012-12-02 20:45:06 +00:00
f19ba32fdd Minor refactor of function call setup to allow for multiple arguments. 2012-11-25 23:07:43 +00:00
afec2544f1 A string interpolation syntax that I don't hate. Also tests.
You can interpolate values into strings using \(this syntax), e.g.

    "best \("str" + "ing") ever"
2012-10-20 00:09:20 +01:00
a4eea165bb Move everything around - delete old Haskell code, clean up build. 2012-09-18 17:44:43 +01:00