-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
834 additions
and
563 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,8 @@ doc/api/ | |
*.js_ | ||
*.js.deps | ||
*.js.map | ||
|
||
# test_coverage | ||
test/.test_coverage.dart | ||
coverage | ||
coverage_badge.svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 'package:json_path/src/ast/node.dart'; | ||
|
||
/// The Abstract Syntax Tree | ||
class AST { | ||
AST(Iterable<String> tokens) { | ||
tokens.skipWhile((_) => _ == r'$').forEach(_processToken); | ||
} | ||
|
||
/// The children of the root node | ||
Iterable<Node> get nodes => _stack.last.children; | ||
|
||
final _stack = <Node>[Node('')]; | ||
|
||
void _processToken(String token) { | ||
if (token == '[') { | ||
_stack.add(Node(token)); | ||
} else if (token == ']') { | ||
final node = _stack.removeLast(); | ||
if (node.value != '[') throw FormatException('Mismatching brackets'); | ||
_stack.last.children.add(node); | ||
} else { | ||
_stack.last.children.add(Node(token)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Iterable<String> tokenize(String expr) => | ||
_tokens.allMatches(expr).map((match) => match.group(0)); | ||
|
||
final _tokens = RegExp([ | ||
r'\$', // root | ||
r'\[', // left bracket | ||
r'\]', // right bracket | ||
r'\.\.', // recursion | ||
r'\.', // child | ||
r'\*', // wildcard | ||
r'\:', // slice | ||
r'\,', // union | ||
r'\?', // filter | ||
r"'(?:[^'\\]|\\.)*'", // quoted string | ||
r'-?\d+', // number | ||
r'([A-Za-z_-][A-Za-z_\d-]*)', // field | ||
].join('|')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.