Stephen Dolan
6828ec9852
Merge pull request #6 from stroan/numeric-comparison-binops
...
Add <,>,<=,>= binops
2012-10-11 07:47:42 -07:00
Stephen Dolan
a2643cc0d5
Allow underscores in IDENT tokens. Fixes #3 .
...
IDENT syntax now includes ASCII letters and underscores, so
'.foo_bar' now works. Non-ASCII letters won't work in IDENT
tokens (it's impossible to tell which non-ascii characters are
"letters" without full unicode tables), so '.données' is still
a syntax error (the workaround is '.["données"]', since you can
put anything you like in a string).
2012-09-22 14:03:46 +01:00
Stephen Dolan
359d5f33bd
Add a bunch of commandline options for controlling I/O format.
...
Also docs for the above. Closes #1 .
2012-09-20 19:31:14 +01:00
Stephen Dolan
92ab193369
Make the <title>s of the doc pages less messy.
2012-09-19 01:15:49 +01:00
Stephen Dolan
fc57cf702c
No HTTPS for me, sadly.
2012-09-19 01:12:33 +01:00
Stephen Dolan
f51eca20f5
Fix some issues with relative URLs on Github Pages.
2012-09-19 01:10:47 +01:00
Stephen Dolan
9887cb57b2
Add a rake task to compile docs into static html.
2012-09-19 01:03:05 +01:00
Stephen Dolan
040604b7db
Use a theme from Bootswatch for docs.
2012-09-19 01:00:25 +01:00
Stephen Dolan
26c7132237
Ensure 'make tarball' creates the required directories.
2012-09-19 00:36:37 +01:00
Stephen Dolan
483f6f2134
Add some release stuff to Makefile.
2012-09-19 00:34:49 +01:00
Stephen Dolan
c463877e17
Add binaries and update download docs.
2012-09-19 00:08:02 +01:00
Stephen Dolan
71ab537ee9
Initialise some variables to keep gcc happy.
2012-09-18 23:46:23 +01:00
Stephen Dolan
134b062be7
Fix a parsing bug for \uXXXX escapes (some invalid escapes were accepted).
...
Found by gcc -O -Wall identifying a use of uninitialised variables.
2012-09-18 23:45:30 +01:00
Stephen Dolan
3898f744dc
Add a README
2012-09-18 23:40:19 +01:00
Stephen Dolan
305059ff9f
Usage messages if jq is run with no arguments.
...
Beats segfaulting.
2012-09-18 23:37:46 +01:00
Stephen Dolan
5863160112
Implement the 'add' builtin promised by the docs' examples.
2012-09-18 23:32:24 +01:00
Stephen Dolan
fbf7bc835b
More docs + docs cleanup
2012-09-18 23:17:27 +01:00
Stephen Dolan
04e85e11de
Print Unicode characters unescaped by default.
2012-09-18 22:47:19 +01:00
Stephen Dolan
20e45f363c
Separate the tests and the main program.
2012-09-18 22:17:13 +01:00
Stephen Dolan
46af5238ce
Add a COPYING file with too many words in it.
2012-09-18 17:59:09 +01:00
Stephen Dolan
cf134909fd
Documentation. Copious.
2012-09-18 17:51:53 +01:00
Stephen Dolan
a4eea165bb
Move everything around - delete old Haskell code, clean up build.
2012-09-18 17:44:43 +01:00
Stephen Dolan
25cbab056b
Slightly better string interpolation.
2012-09-18 13:22:22 +01:00
Stephen Dolan
8041ce3119
Add the builtin 'select' function.
2012-09-18 12:58:39 +01:00
Stephen Dolan
8f0c91c032
Add a missing file from prev commit
2012-09-18 12:58:29 +01:00
Stephen Dolan
940f8c4270
Builtin functions defined in jq.
2012-09-18 10:17:38 +01:00
Stephen Dolan
5b9bb64a88
-Werror was a little overzealous.
...
Older versions of gcc warn about random things. -Werror makes the
built fail on such compilers.
2012-09-18 09:43:44 +01:00
Stephen Dolan
7d8d97933f
Builtin function 'type'.
2012-09-17 23:06:48 +01:00
Stephen Dolan
f13865d7a1
Fix a precedence bug.
...
a == b or c == d should obviously parse as (a==b) or (c==d).
2012-09-17 22:37:51 +01:00
Stephen Dolan
49cf2e67fe
Recursive functions + bugfix for stack reallocation.
2012-09-17 22:32:06 +01:00
Stephen Dolan
cbdeddbab8
Make the code compile with warnings-as-errors.
...
-Wextra found a bona-fide bug: signed/unsigned comparison in a
stack overflow check.
2012-09-17 22:04:58 +01:00
Stephen Dolan
eab9c4e587
Fix debugging code in execute.c so that debug jq compiles again.
2012-09-17 21:43:10 +01:00
Stephen Dolan
830610cef8
Make "not" a builtin function rather than syntax.
...
Fixes a really awkward grammar issue.
2012-09-17 21:08:43 +01:00
Stephen Dolan
297a0679d1
Redefine true and false. Define empty, distict from null.
...
This might be the most philosophical commit. I shall ponder it.
true, false, null, empty now defined as bytecoded builtins rather
than calls out to C functions.
2012-09-17 20:59:34 +01:00
Stephen Dolan
fe33150b7f
Merge branch 'master' of github:stedolan/jq
...
Conflicts:
c/builtin.c
2012-09-17 20:49:41 +01:00
Stephen Dolan
3db27b01a1
First pass at string interpolation.
...
Requires a lexer hack, but a surprisingly un-hideous one. The lexer
maintains a stack of bracket characters so that it can match
parens/brackets/braces to tell where a subexp nested in a string
actually ends.
2012-09-17 20:41:57 +01:00
Stephen Dolan
326771f4b4
Add a "tostring" function.
2012-09-17 20:14:07 +01:00
Stephen Dolan
9c15ad2021
Support rendering a JSON value to a string buffer.
2012-09-17 20:11:12 +01:00
Stephen Dolan
84ea129f26
Better support for appending strings in JV.
2012-09-17 19:41:41 +01:00
Stephen Dolan
50ebb036c4
Bind builtin functions in a slightly less ugly way.
2012-09-16 17:08:56 +01:00
Stephen Dolan
539156430a
Builtin function 'length', for arrays/objects/strings.
2012-09-16 11:08:42 +01:00
Stephen Dolan
cc2fb20ca0
Hrm. Update operators (//=, +=, etc.) aren't very well thought out.
...
In complex cases, their behaviour is kinda weird. Here's a failing
test for what I think they should do.
2012-09-16 11:07:36 +01:00
Stephen Dolan
df195b3187
Add update operators (+=, -=, *=, /= and //=)
2012-09-11 23:55:59 +01:00
Stephen Dolan
f6c6ba95ad
Make .[] capable of iteration over objects as well as arrays.
...
Also change an assert to a proper error message if it's given
something silly like a number.
2012-09-11 16:10:55 +01:00
Stephen Dolan
d9d6f43407
Pretty-printing of JSON values.
2012-09-11 15:53:37 +01:00
Stephen Dolan
51a44edc63
JSON stream parser.
...
Allow multiple values on input as concatenated JSON objects,
possibly separated by whitespace.
2012-09-11 14:52:10 +01:00
Stephen Dolan
062a6aa6d7
More error handling - locations of refs to undefined symbols.
2012-09-11 12:24:54 +01:00
Stephen Dolan
4c7bede5a4
Better error handling and messages for invalid index/assign operations.
2012-09-11 10:37:44 +01:00
Stephen Dolan
0ce437ea97
More error handling in the parser.
...
Add a special case in the lexer to detect unterminated strings.
Add some error recovery in the parser for more copious error spam.
2012-09-11 10:18:18 +01:00
Stephen Dolan
ac3f8bcc52
Proper error messages from lexer errors (e.g. bad characters).
2012-09-11 09:13:20 +01:00
Stephen Dolan
95dd64b0f0
Much, much better error reporting from the parser.
...
Getting proper locations through flex/bison was more effort than
was advertised.
2012-09-11 00:04:47 +01:00
Stephen Dolan
4d47f8f1e1
'==' operator, tests for equality and operator precedence.
2012-09-10 18:08:00 +01:00
Stephen Dolan
3895bbf856
String -> number conversions with "tonumber".
2012-09-10 17:08:13 +01:00
Stephen Dolan
aa3ebdfe9b
Multiplication and division operators.
...
It is an error to use these on anything but numbers. Maybe later
implementing python/ruby-style ("a" * 100) might be handy.
2012-09-10 16:57:17 +01:00
Stephen Dolan
6f3abbac62
Subtraction - as expected for numbers, ruby-style set diff for arrays.
2012-09-10 16:49:25 +01:00
Stephen Dolan
65ce73deb4
String concatenation.
2012-09-10 16:16:39 +01:00
Stephen Dolan
e718bd50b6
Sensible error messages when a silly addition is performed.
...
Fix a test to no longer perform an invalid addition.
2012-09-10 16:15:05 +01:00
Stephen Dolan
a3e509034b
jv_string_fmt (create printf-formatted JSON strings)
2012-09-10 16:01:56 +01:00
Stephen Dolan
0159c0ecc5
Plug a memory leak in jv_object_merge
2012-09-10 15:08:58 +01:00
Stephen Dolan
649cac791a
Make jv_invalid() first-class values capable of holding an error.
2012-09-10 15:04:19 +01:00
Stephen Dolan
5c25c90657
When comparing two objects for equality, we don't need to recurse
...
into e.g. array elements if the two objects are the same array.
2012-09-10 13:06:46 +01:00
Stephen Dolan
c2593dc417
Make a main program that doesn't spam debugging info.
2012-09-10 10:23:15 +01:00
Stephen Dolan
e258d20ba2
Make the '+' operator merge objects.
2012-09-09 19:17:07 +01:00
Stephen Dolan
a4ff3d4670
Bugfix for expanding objects.
2012-09-09 18:09:05 +01:00
Stephen Dolan
e6a85737da
Print bad number values (Inf,NaN) "correctly".
2012-09-09 15:35:34 +01:00
Stephen Dolan
0dfaebcdcb
null and string literals now exist, so add tests
2012-09-06 21:44:46 +01:00
Stephen Dolan
0fd7d4b30c
UTF8 coding utilities and unicode escaping in jv_dump()'d strings.
...
Beyond the Basic Multilingual Plane, dead Cthulhu waits dreaming.
2012-09-06 21:39:00 +01:00
Stephen Dolan
58a9b0cfe1
Make the test harness not segfault when a test fails (!)
2012-09-04 20:56:44 +01:00
Stephen Dolan
da5d653de8
Add a Boolean "not" operator.
...
Not wholly convinced this is a good idea, maybe "not" should be a
builtin function instead? 'not (.a == .b)' vs. '.a == .b | not'
2012-09-04 20:43:40 +01:00
Stephen Dolan
6e6ea50763
Short-circuiting Boolean "and" and "or" operators.
2012-09-04 20:38:59 +01:00
Stephen Dolan
c5ab3b2336
Move some unicode handling stuff to a separate file.
2012-09-04 20:38:47 +01:00
Stephen Dolan
328c4a13f1
Add "elif" to if-then-else constructs.
2012-09-04 16:05:24 +01:00
Stephen Dolan
5add2c2ceb
if-then-else and defined-or operators
2012-09-04 15:34:34 +01:00
Stephen Dolan
520c7bb15e
Fix some confusion between "null" and "invalid".
2012-09-03 17:26:52 +01:00
Stephen Dolan
32e324a283
Fix a memory leak in JV and add more tests
2012-09-03 17:18:10 +01:00
Stephen Dolan
eea05ff924
Perl-style autovivification.
...
.foo.bar = 1 will cause objects to be created if they don't exist.
2012-09-03 16:50:38 +01:00
Stephen Dolan
c9dbe1aff8
squash a debug printf
2012-09-03 16:42:58 +01:00
Stephen Dolan
a8c3648ca5
JV_KIND_INVALID values to represent failed lookups, etc + various tests.
2012-09-03 16:16:14 +01:00
Stephen Dolan
d895d39ba9
Support "null" in JQ programs
2012-09-03 16:14:52 +01:00
Stephen Dolan
8fe9c8a22a
Make assignment work again: = and |= operators.
2012-09-03 15:33:59 +01:00
Stephen Dolan
d8fad1ed9b
Disallow a + before numbers (makes parsing easier, agrees with JSON)
2012-09-03 15:32:50 +01:00
Stephen Dolan
cf004c2b3a
Modify number formatting so that 1e-3 renders as 0.001, not .001
2012-09-03 13:57:53 +01:00
Stephen Dolan
6041fd7661
Literal strings and better literal numbers.
2012-09-03 13:57:47 +01:00
Stephen Dolan
52487ff812
Remove globals from parser, use explicit structure.
2012-09-03 01:12:42 +01:00
Stephen Dolan
22ffc0fdfc
Mark a constant array const in jvp_dtoa.c
2012-09-02 22:24:27 +01:00
Stephen Dolan
e3710c0d1f
Fix behaviour of stack at program termination.
2012-09-02 22:11:06 +01:00
Stephen Dolan
4f747e6fff
Move from Jansson to JV - proper freeing of memory
...
A few more tests, now passes valgrind.
2012-09-02 21:45:52 +01:00
Stephen Dolan
9da3e0d373
Clean up build a little and add .gitignore.
2012-09-02 17:24:17 +01:00
Stephen Dolan
f72c5ffac0
Move from Jansson to JV - interpreter loop
...
Passes tests, but leaks some memory.
2012-09-02 17:20:13 +01:00
Stephen Dolan
2cb9a6e61d
Move from Jansson to JV - everything but the interpreter loop
...
Passes valgrind --leak-check=full.
2012-09-02 16:31:59 +01:00
Stephen Dolan
22f8aed31e
Validation for empty objects
...
Now (correctly) fails to parse {,}
2012-09-02 00:24:23 +01:00
Stephen Dolan
e98624e5a9
First pass at a JSON parser
2012-09-01 19:16:43 +01:00
Stephen Dolan
92654f8204
Fix a memory leak when inserting into an object with an already-present key
2012-09-01 18:24:17 +01:00
Stephen Dolan
66fd702363
Minor changes to dtoa.c to make it easier to work with.
...
- Change memory allocation to thread a context structure through
the code rather than using globals (which would require a
-lpthread and some locking to become threadsafe).
- Remove a few configuration options (the "private memory" space,
and K&R style headers).
- Prefix exported symbols with jvp_ to prevent libc conflicts.
- Add jvp_dtoa.h
- Include netlib's g_fmt.c into dtoa.c
- Add a few not-strictly-necessary initialisations in order to
compile cleanly with gcc -Wall
2012-09-01 18:01:35 +01:00
Stephen Dolan
9e544c55dc
Import a copy of David Gay's dtoa.c
2012-09-01 16:50:25 +01:00
Stephen Dolan
f25cb16e6b
Fix a bug in lexical scoping, add tests
2012-08-28 18:38:30 +01:00
Stephen Dolan
463b175cdb
Reference-counted copy-on-write JSON library.
...
Comes with tests and, presumably, bugs.
2012-08-28 18:09:43 +01:00
Stephen Dolan
dc6cf2fb58
Remove syntax distinction between builtin and user calls
2012-08-27 11:19:42 +01:00
Stephen Dolan
6c8b55793a
first pass at assignment
2012-08-27 10:12:02 +01:00
Stephen Dolan
a847d2250f
2nd order functions
2012-08-26 14:25:56 +01:00