summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Jo-Philipp Wich [Thu, 19 Jun 2014 09:21:41 +0000 (11:21 +0200)]
cli: add a flag to specify arbritary field separators
This is useful to join values with a specified char instead of the
default space.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Wed, 18 Jun 2014 15:59:51 +0000 (17:59 +0200)]
Improve error reporting
Keep track of the exact location the error occured in and switch
the internal error description from a dynamic string buffer to an
integer which either holds negative values for lexer errors or
positives values for grammer violations.
In case of grammer violations the "error_code" member will hold
a bitfield describing the expected tokens.
Also rework the error messages emitted by the cli to be more
precise.
Examples:
$ jsonfilter -s '{}' -e '@.foo bar'
Syntax error: Expecting End of file
In expression @.foo bar
Near here ----------^
$ jsonfilter -s '{}' -e '@.foo\bar'
Syntax error: Unexpected character
In expression @.foo\bar
Near here ---------^
$ jsonfilter -s '{}' -e '@.foo..bar'
Syntax error: Expecting Label or '*'
In expression @.foo..bar
Near here ----------^
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Wed, 18 Jun 2014 09:33:41 +0000 (11:33 +0200)]
cli: minor whitespace fix
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Sun, 15 Jun 2014 14:31:14 +0000 (16:31 +0200)]
Switch to sqlite3's lemon parser generator.
This commit drops the flex + bison code in favor to a hand-written
lexer and a new grammar file in lemon syntax.
The change results in a much smaller binary and easier to maintain
code. Code required to build and maintain the AST has been split
off into the ast.c and ast.h files.
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Fri, 13 Jun 2014 13:26:37 +0000 (15:26 +0200)]
build: use -ffunction-sections and --gc-sections
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
Jo-Philipp Wich [Mon, 6 Jan 2014 11:55:44 +0000 (11:55 +0000)]
cli: supress printing "null" in non-export mode, output strings unescaped
Jo-Philipp Wich [Thu, 2 Jan 2014 12:51:59 +0000 (12:51 +0000)]
Update copyright
Jo-Philipp Wich [Wed, 1 Jan 2014 21:39:23 +0000 (21:39 +0000)]
parser: fix error reporting
Jo-Philipp Wich [Wed, 1 Jan 2014 21:38:08 +0000 (21:38 +0000)]
lexer, parser, matcher: extend grammar to allow comma separated keys/indexes as more readable alternative to or expressions
Jo-Philipp Wich [Wed, 1 Jan 2014 15:44:00 +0000 (15:44 +0000)]
cli: gather all found items through a callback function
Jo-Philipp Wich [Wed, 1 Jan 2014 15:39:20 +0000 (15:39 +0000)]
matcher: add user callback and support implicit index/key compares
- introduced callback argument in jp_match() which is invoked for each found json item
- when chaining strings or numbers in or expressions, implicitely match them against the current key
Jo-Philipp Wich [Tue, 31 Dec 2013 00:07:06 +0000 (00:07 +0000)]
lexer: accept single quoted string literals
Jo-Philipp Wich [Sun, 29 Dec 2013 21:31:35 +0000 (21:31 +0000)]
parser: fix order of declarations
Jo-Philipp Wich [Sun, 29 Dec 2013 21:19:11 +0000 (21:19 +0000)]
cli: implemnt -s flag to pass json source as string argument
Jo-Philipp Wich [Sun, 29 Dec 2013 21:05:44 +0000 (21:05 +0000)]
cli: additional flags and cleanup
* add -q flag to suppress error messages
* add -t flag to test type of result
* clean up exit codes to indicate success;
- 0 if all -t and -e expression yielded a result
- 1 if at least one -t or -e expression didn't match
- 125 when failed to open input file
- 126 when failed to parse json input
- 127 when the farser fails due to oom
Jo-Philipp Wich [Sun, 29 Dec 2013 21:03:51 +0000 (21:03 +0000)]
parser: change exitcode in case of oom errors
Jo-Philipp Wich [Sun, 29 Dec 2013 18:07:40 +0000 (18:07 +0000)]
Amend gitignore
Jo-Philipp Wich [Sun, 29 Dec 2013 18:07:00 +0000 (18:07 +0000)]
Add gitignore file
Jo-Philipp Wich [Sun, 29 Dec 2013 18:03:10 +0000 (18:03 +0000)]
eliminate global variables and use a private parser/lexer state
Jo-Philipp Wich [Sun, 29 Dec 2013 18:02:04 +0000 (18:02 +0000)]
cmake: let generated lexer.c, parser.c depend on their respective source files, clean generated headers
Jo-Philipp Wich [Sat, 28 Dec 2013 21:26:59 +0000 (21:26 +0000)]
Remove generated files
Jo-Philipp Wich [Sat, 28 Dec 2013 21:25:20 +0000 (21:25 +0000)]
Initial commit