From 72397506c3529f4878b5a1cf8205599764ac4088 Mon Sep 17 00:00:00 2001 From: SoniEx2 Date: Sun, 13 Nov 2022 12:30:11 -0300 Subject: Finish most "core" VM functionality Still need to do lists --- src/lib.rs | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index bda97f4..6d8a7e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,6 +14,8 @@ //! //! ## Syntax Elements of Datafu Expressions //! +//! FIXME still need to update these... +//! //! An arrow is `->` and indicates indexing/iteration. Whether indexing or //! iteration is used is defined by the elements that follow, with iteration //! being used by default. @@ -89,7 +91,7 @@ //! arg ::= parameter | literal | regex | keymatch //! //! arrow ::= '->' -//! keymatch ::= '[' [name] expression ']' +//! keymatch ::= '[' [name] expression ']' ['?'] //! subvalue ::= '(' expression ')' ['?'] //! ``` //! @@ -98,7 +100,27 @@ //! //! # Examples //! -//! +//! The Datafu pattern +//! +//! ```datafu +//! :map +//! ->['a'?]:map +//! ->[b:?str]:?map +//! (->['x'?]x:?bool) +//! (->['y'?]y:?bool)? +//! ``` +//! +//! When matched against the JSON +//! +//! ```json +//! {"a": {"1": {"y": true}, "2": {"x": true, "y": true}}} +//! ``` +//! +//! Produces the results for the sub-JSON +//! +//! ```json +//! {"a": {"2": {"x": true, "y": true}}} +//! ``` pub mod errors; //pub mod type_tree; -- cgit 1.4.1