2 releases

0.1.1 Sep 22, 2020
0.1.0 Sep 8, 2020

#106 in #query-language


Used in 3 crates (via ogma-libs)

MIT/Apache

54KB
1K SLoC

Natural Object Query Language

The goal of the Natural Object Query Language (or NOQL) is to have an plain old English representation of an object query

type QueryList<'a> = Vec<Query<'a>>;

enum Query<'a> {
  Index {
    index: usize,
    from_end: bool
  },
  Key(&'a str)
}

where an object can take a list of query segments and either index a list or get a key from a map

Index

the ((first|second|third|fourth|fifth|sixth|seventh|eighth|ninth|tenth|eleventh|twelfth|#st|#nd|#rd|#th) [to last]|last) item

where # is a positive integer

Key

the [key|`key`|`multi word key`]

handlers of the key can choose to "dehumanize" the key however they want

Query List

(index|key) [of (index|key) [of (index|key) ...]]

query segments are chained with of


lib.rs:

Parses natural language to produce a Vec<Query>. The main entrypoints are from_slice and from_str

Dependencies

~215KB