summaryrefslogtreecommitdiffstats
path: root/execute.c
AgeCommit message (Collapse)Author
2015-07-26Error on bytecodes longer than 0xFFFF (fix #269)David Tolnay
This lets us use uint16_t for the program counter. JVM languages have the same limit on method size so it is a reasonable limit.
2015-07-24detect invalid path expression (fix #862)David Tolnay
2015-07-19Clean up trailing whitespaceDavid Tolnay
2015-05-21Print offending object in runtime error messagesAssaf Gordon
When reporting an error to the user, add information about the offending object/value (possibly truncated). The goal is to give a user some context regarding which input object caused the runtime error. Examples: $ echo '"hello"' | ./jq '-.' jq: error: string ("hello") cannot be negated $ echo '"very-long-string"' | ./jq '-.' jq: error: string ("very-long-...) cannot be negated $ echo '["1",2]' | ./jq '.|join(",")' jq: error: string (",") and number (2) cannot be added $ echo '["1","2",{"a":{"b":{"c":33}}}]' | ./jq '.|join(",")' jq: error: string (",") and object ({"a":{"b":{...) cannot be added $ echo '{"a":{"b":{"c":33}}}' | ./jq '.a | @tsv' jq: error: object ({"b":{"c":33}}) cannot be tsv-formatted, only array (Fix #754)
2015-03-30Include filename and lineno in error messagesNicolas Williams
2015-02-13Reduce number of msg callback typedefsNicolas Williams
2014-12-31Further module system revamp (fix #659)Nicolas Williams
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-30Add `label $name | EXP`; fix `break`Nicolas Williams
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-30Allow resetting of jq err callbackNicolas Williams
This will be useful for the upcoming test-erroneous-programs improvement to --run-tests, so we can switch between the default error reporting method (print to stderr) to a method internal to --run-tests, and back. The idea is that when testing programs that are expected to compile (and link), it'd be nice if errors continue going to stderr, while when testing programs that must fail to compile (or link), the error has to be captured so it can be compared to the error expected by the test.
2014-12-27Add `debug` builtinNicolas Williams
And refactor setup of jv dump flags.
2014-12-26Add Streaming parser (--stream)Nicolas Williams
Streaming means that outputs are produced as soon as possible. With the `foreach` syntax one can write programs which reduce portions of the streaming parse of a large input (reduce into proper JSON values, for example), and discard the rest, processing incrementally. This: $ jq -c --stream . should produce the same output as this: $ jq -c '. as $dot | path(..) as $p | $dot | getpath($p) | [$p,.]' The output of `jq --stream .` should be a sequence of`[[<path>],<leaf>]` and `[[<path>]]` values. The latter indicate that the array/object at that path ended. Scalars and empty arrays and objects are leaf values for this purpose. For example, a truncated input produces a path as soon as possible, then later the error: $ printf '[0,\n'|./jq -c --stream . [[0],0] parse error: Unfinished JSON term at EOF at line 3, column 0 $
2014-12-26Allow C-coded functions to `empty`Nicolas Williams
Just return a jv_invalid() without a message.
2014-12-24Module search revamp for pkg managersNicolas Williams
The search path listed in an import directive can now be an array. The top-level search path is appended. Null and empty strings in the path terminate any search. The "." in "." and "./*" is replaced with the directory containing the file doing the import (for command-line programs this is the current directory, though that may be a bad idea). No version numbers or anything of the sort are gratuitously added to the search paths. All this makes external package managers possible by allowing dependencies to be installed local to dependents.
2014-12-23Use __attribute__ __printf__ with GCCNicolas Williams
2014-11-29Fix refcount leak, fix #618Nicolas Williams
2014-11-28STOREV/LOADV* should also print refcntsNicolas Williams
2014-11-28Enable printing of stack val refcntsNicolas Williams
2014-08-30Drop the jq version directory from search pathNicolas Williams
2014-08-14Add `module` directive, `modulemeta` builtinNicolas Williams
Fix #425.
2014-08-14Add jq_report_error() function; use itNicolas Williams
Put a stop to fprintf(stderr, ...) where we shouldn't.
2014-07-22Added library system with -l, -L, and JQ_LIBRARY_PATHWilliam Langford
Created util.[ch] to hold common utilities.
2014-07-10Fix #478 assertion failureNicolas Williams
2014-07-07Make C-coded built-ins take `jq_state *` argumentNicolas Williams
2014-07-07Better check for lib has only functions (fix #138)Nicolas Williams
2014-07-06Add `try EXP catch EXP`Nicolas Williams
2014-07-01Fix off-by-one in TCONicolas Williams
Now we have the ability to define a generator in jq: def for(cond; update): def _for: if cond then ., (update | _for) else . end; _for; for(. < 10; . + 1) # generates numbers between `.` and 10 Running this by hand with --debug-dump-disasm (with a fix for that coming up next) we can see that the call to _for is optimized: _for:0: 0000 DUP 0001 CALL_JQ cond:0^1 0005 JUMP_F 0022 0007 POP 0008 FORK 0012 0010 JUMP 0020 0012 CALL_JQ update:1^1 0016 TAIL_CALL_JQ _for:0^1 0020 JUMP 0023 0022 POP 0023 RET And timing this with 1000, 10000, 100000 iterations shows that indeed we must be applying TCO; otherwise, without TCO, this gets very slow very quickly.
2014-06-30TCO to the max!Nicolas Williams
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-30Add much commentary about CALL_JQ and call framesNicolas Williams
2014-06-23Improve TCONicolas Williams
Instead of checking for self-recursion check that the thing we're calling is a function and not a closure, therefore the new frame will have the same env as the current frame.
2014-06-22Tail call optimization (close #437)Nicolas Williams
2014-02-20Add `?`, `.[]?`, and `..` operatorsNicolas Williams
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 '|'.
2013-12-08args to jq_compile_args were not getting freed when there were errors in the ↵David R. MacIver
compile
2013-12-06Fix double-free typo in print_error()Nicolas Williams
2013-12-04Add callback interface for errorsNicolas Williams
Printing to stderr is not the right answer for a library.
2013-06-22Merge branch 'header-cleanup' into libjqStephen Dolan
Conflicts: Makefile.am
2013-06-21Add libjq autoconf gooNicolas Williams
2013-06-21Move cfunction invocation code to the interpreter loop.header-cleanupStephen Dolan
2013-06-18Fold opcode.{c,h} into bytecode.{c,h}Stephen Dolan
2013-06-18Remove some initialise-to-zero code.Stephen Dolan
This lets valgrind find more bugs - if a field isn't given a well-defined value valgrind will now find it instead of seeing it set to zero with memset.
2013-06-18Merge branch 'stack-refactor'Stephen Dolan
Conflicts: execute.c
2013-06-15Fixup API to get closer to a libjqNicolas Williams
2013-06-14Clean up lots of stack and frame logic.Stephen Dolan
Move frame defs to execute.c
2013-06-14Simplify frame logic.Stephen Dolan
2013-06-13Unify all stacks. Passes tests, but needs cleanup.Stephen Dolan
2013-06-10Unify frame and data stacksStephen Dolan
2013-05-29Load library from ~/.jqBrendan Macmillan
2013-05-17EACH need not make a backtrack point on the last iterationStephen Dolan
2013-05-16Add LOADVN opcode.Stephen Dolan
Does a variable load, but sets the variable to be null afterwards.
2013-05-15Remove the YIELD opcode (use RET instead)Stephen Dolan
2013-05-14Add the range functionStephen Dolan