Documentation
¶
Overview ¶
Package fql implements a tokenizer for FQL.
The acronym FQL stands for Filtering Query Language which is a custom syntax for describing how to filter a requested resource. The intended method for sending fql to a server is to pass it as a query parameter value in the request's URL.
https://www.example.com/resource?f=<fqlString>
Tokenization is done by creating a Tokenizer for a string that contains the fql.
z := fql.NewTokenizer(fqlString)
Given a Tokenizer z, the FQL is tokenized by repeatedly calling z.Next(), which parses the next token and returns it, or an error. If the returned token is fql.RULE, then calling z.Rule() will return the parsed *fql.Rule value that is associated with that token.
for { tok, err := z.Next() if err != nil { if err != fql.EOF { return err } break } switch tok { case fql.LPAREN: // ... case fql.RPAREN: // ... case fql.AND: // ... case fql.OR: // ... case fql.RULE: r := z.Rule() // ... } }
Index ¶
Constants ¶
const (
Null nullbit = true // Null represents a "null" value in a filter rule.
)
Variables ¶
var EOF = io.EOF
EOF is the error returned by the Tokenizer when no more input is available.
The io.EOF value is re-declared here only so that client code will not have to import the "io" package when using the "fql" package.
Functions ¶
This section is empty.
Types ¶
type CmpOp ¶
type CmpOp uint32
CmpOp represents a comparison operator.
const ( CmpEq CmpOp // ":" equality operator CmpNe // ":!" inequality operator CmpGt // ":>" greater-than operator CmpLt // ":<" less-than operator CmpGe // ":>=" greater-than-or-equal operator CmpLe // ":<=" less-than-or-equal operator )
type Error ¶
type Token ¶
type Token uint32
A Token is the set of lexical tokens of FQL.
const ( LPAREN Token // ( RPAREN // ) AND // ; OR // , RULE // <key>:[op]<value> )