Commit Graph

505 Commits

Author SHA1 Message Date
eanderton 12e974f892 Query interface with callback functions
* Added public Query interface
* Added filter function callback support
* Added "script" function callback support

Queries are generated via Compile(), which then may be run via Execute()
as many times as needed.  Much like compiling a regex, this is done to
elide the need to re-parse and build the funciton tree for each
execution.

The distinction between 'filter' and 'script' is borrowed from their
syntactic equivalents in jsonpath.  Right now, these accept no arguments
in the query, and instead merely pass the current node to the callback.
Filters return a bool and determine if the node is kept or culled out.
'Scripts' return a string or an in64, which is in turn used in an index
or key filter (respectively) on the current node's data.

A few callbacks are provided by default, with the ability to add
additional callbacks before calling Execute() on a compiled query.
2014-09-08 22:08:28 -04:00
eanderton c81f1892c2 Refactored match to use function chaining 2014-09-07 16:32:29 -04:00
eanderton a98788e0d7 Added additional parser tests 2014-09-07 09:01:58 -04:00
eanderton b74544d345 Changed match func strategy; added tests
As it turns out, closures are very hard to validate without running them.
Since table-driven tests tend to rely on value types that can be
compared directly, using structs that adhere to a generic callback
interface is more work, but is more easily tested.

* Changed jsonpath match functions to structs with Call() methods
* Added tests to verify the generation of jsonpath QueryPath data
* Added tests to verify jsonpath lexer
* Fixed jsonpath whitespace handling bug
* Fixed numerous flaws in jsonpath parser
2014-09-04 23:17:29 -04:00
eanderton 27416cc1b9 gofmt pass 2014-09-04 07:30:19 -04:00
eanderton 04b60e4f8d revised matching strategy 2014-09-04 07:19:35 -04:00
eanderton 9942463786 semi-functional prototype 2014-09-03 21:33:25 -04:00
Thomas Pelletier fb5423fba2 Fixes #22: Fixes style issues 2014-08-29 18:24:51 +02:00
Thomas Pelletier a2495b4806 Add positions in README 2014-08-29 17:31:58 +02:00
Thomas Pelletier e118479061 Merge pull request #21 from eanderton/master
Element Position Support
2014-08-29 17:12:06 +02:00
eanderton c0c5d65185 Removed redudant license info 2014-08-27 21:18:07 -04:00
eanderton 7c63fff960 Added Position Support to TomlTree
TomlDocument provides an optional TOML processing path where position
informaiton is stored alongside a TomlTree.
* Added Position struct
* Revised TomlTree to contain position data
* Added tomlValue to bind positions to values
* Revised parser to emit position data
* Revised token to use new Position struct
* Added tests for new functionality
* Bugfixed table array duplicate key handling
* Applied gofmt to all code
2014-08-26 21:00:41 -04:00
Thomas Pelletier bcbaee1079 Use SVG for the Travis badge 2014-08-23 15:40:43 +02:00
Thomas Pelletier f15dd550e8 Add godoc badge 2014-08-23 15:31:59 +02:00
Thomas Pelletier 5ad4cb7120 Add 1.3 to Travis' build matrix 2014-08-14 10:14:50 +02:00
Thomas Pelletier 65684e6bb0 Fixes #20 : Creation of subgroup in table arrays 2014-08-14 10:12:39 +02:00
Thomas Pelletier 68d2a60b37 Merge branch 'eanderton-master' 2014-08-07 12:53:56 +02:00
Thomas Pelletier bf549a2194 Run gofmt 2014-08-07 12:52:42 +02:00
eanderton aa194b5c41 Revised error message in parser test 2014-08-06 20:30:30 -04:00
eanderton 14e2d94bdd Added missing test entry 2014-08-06 20:28:44 -04:00
eanderton 1f8a8cbc06 Added error context for parsing of subtrees 2014-08-06 08:20:53 -04:00
eanderton 6db660fed5 Revised error formatting, fixed tests 2014-08-06 08:15:05 -04:00
eanderton 7d9a3c25bd Revised error reporting 2014-08-06 07:34:01 -04:00
eanderton dd04a2f3cd Added line/col support to lexer 2014-08-06 07:13:15 -04:00
Thomas Pelletier e493544dfd Merge pull request #18 from simia-tech/master
extended Has function to work with paths
2014-07-10 16:28:49 +02:00
Philipp Brüll e9ae961088 extended Has function to work with paths 2014-07-09 16:34:41 +02:00
Thomas Pelletier c1ad095e9b Update README.md
Update the supported TOML version and the command to run the tests.
2014-07-09 07:40:16 +02:00
Thomas Pelletier 86a7f2508e Merge pull request #17 from eanderton/master
TOML v0.2.0 Group Array Support and ToString Feature
v0.2.0
2014-07-09 07:34:48 +02:00
eanderton 713478a34e Dropped travis support for go v1.0 2014-07-08 22:12:58 -04:00
eanderton 5dd3b53635 Fixed formatting 2014-07-08 22:02:42 -04:00
eanderton 262211488d Fixed path handling and key group array name lexing for test compliance 2014-07-08 22:00:46 -04:00
eanderton abdecb7be7 Refactored testing approach to use 'vendorized' libraries at test time. 2014-07-08 21:26:30 -04:00
eanderton f69e0b0837 merged from pelletier/go-toml 2014-07-08 18:38:07 -04:00
Thomas Pelletier cd055fa448 Remove outdated test dependency 2014-07-08 07:38:28 +02:00
eanderton c9ea292f59 Additional formatting 2014-07-07 21:08:57 -04:00
eanderton 7b208738bc Fixed formatting; added name to license file 2014-07-07 21:06:42 -04:00
eanderton c8b5633273 Group array support; ToString() support 2014-07-07 20:48:29 -04:00
Thomas Pelletier b28c2d0c9e Merge pull request #16 from half-ogre/15-fix-parser-on-windows
Fix parser on Windows
2014-02-21 14:27:47 +01:00
half-ogre 1c0f7f552c \r is not a keychar on Windows 2014-02-20 14:51:43 -08:00
Thomas Pelletier 0773148832 Merge branch 'master' of github.com:pelletier/go-toml 2013-12-10 22:00:49 +01:00
Thomas Pelletier fbf99a1816 Add Go 1.2 to the build matrix 2013-12-10 21:55:30 +01:00
Thomas Pelletier 1cfdab9cee Merge pull request #14 from pelletier/pelletier/go_test_support
Add BurntSushi's test suite
2013-12-10 12:52:51 -08:00
Thomas Pelletier dc20c454d7 Handle dots in keys 2013-12-10 21:51:40 +01:00
Thomas Pelletier 0c4e891f3e Handle non-alpha chars in keys 2013-12-10 19:46:56 +01:00
Thomas Pelletier b1d602f733 Add missing string escape sequences 2013-12-10 19:35:47 +01:00
Thomas Pelletier a4d623ad05 Fix implicit declaration 2013-12-10 19:29:01 +01:00
Thomas Pelletier 4fdde9794a Output JSON for test suite
Reused @BurntSushi's
2013-12-10 19:00:35 +01:00
Thomas Pelletier 3085454477 Don't allow duplicate keys 2013-12-10 17:50:59 +01:00
Thomas Pelletier 01609e0ab7 Add some tests for nested empty arrays 2013-12-10 17:46:30 +01:00
Thomas Pelletier a34fc5f051 Don't allow invalid escape sequences 2013-12-10 17:34:11 +01:00