Liking cljdoc? Tell your friends :D

instacheck.grammar


apply-grammar-updateclj/s

(apply-grammar-update grammar utrek)

Takes a grammar and an map of grammar paths to grammar nodes (an update-trek). Replaces each update path in the grammar ith the new update node.

Takes a grammar and an map of grammar paths to grammar nodes (an
update-trek). Replaces each update path in the grammar ith the new
update node.
raw docstring

assoc-in-grammarclj/s

(assoc-in-grammar grammar path value)

Update a grammar node at the given path in grammar to a new value. Like assoc-in for grammars.

Update a grammar node at the given path in grammar to a new value.
Like assoc-in for grammars.
raw docstring

CHILD-EDGEclj/s

(CHILD-EDGE e)

children-of-nodeclj/s

(children-of-node grammar path)

Given a grammar and path node within that grammar return the paths of the children (:alt, :ord, and :cat nodes).

Given a grammar and path node within that grammar return the paths
of the children (:alt, :ord, and :cat nodes).
raw docstring

combine-stringsclj/s

(combine-strings grammar)

Combine strings and spaces that immediately follow each other in a concatenation.

Combine strings and spaces that immediately follow each other in
a concatenation.
raw docstring

comment-trekclj/s

(comment-trek grammar & [comment-tx])

Return a trek with comment values (map of grammar paths to parsed comments) by reading edn maps from comments in the grammar. Note that this will return different paths than a normal trek because a comments can occur on any :alt/:ord nodes and since comments can occur in internal :alt/:ord nodes a comment trek will have these internal nodes (a regular trek will not).

Multiple comments with edn maps in the same node will be merged into a single map. If the optional comment-tx function is provided it will be applied to the merge maps values.

This requires a patched version of instaparse to retain the comments in the grammar on :comments keys.

Return a trek with comment values (map of grammar paths to parsed
comments) by reading edn maps from comments in the grammar. Note
that this will return different paths than a normal trek because
a comments can occur on any :alt/:ord nodes and since comments can
occur in internal :alt/:ord nodes a comment trek will have these
internal nodes (a regular trek will not).

Multiple comments with edn maps in the same node will be merged into
a single map. If the optional comment-tx function is provided it
will be applied to the merge maps values.

This requires a patched version of instaparse to retain the comments
in the grammar on :comments keys.
raw docstring

get-ancestorsclj/s

(get-ancestors grammar path pred)

Returns a vector of paths for which each p in the vector is a parent edge of path in grammar for which (pred p) is true. For example, to find the nearest parent :cat nodes of my-path: (get-ancestors g my-path #(= :cat (last %)))

Returns a vector of paths for which each p in the vector is
a parent edge of path in grammar for which (pred p) is true. For
example, to find the nearest parent :cat nodes of my-path:
(get-ancestors g my-path #(= :cat (last %)))
raw docstring

get-ancestors*clj/s

(get-ancestors* grammar path pred avoid)

get-descendantsclj/s

(get-descendants grammar path pred)

Return a set of paths for which each p in the set is a descendent of path for which (pred p) is true.

Return a set of paths for which each p in the set is a descendent
of path for which (pred p) is true.
raw docstring

get-descendants*clj/s

(get-descendants* grammar path pred avoid)

get-in-grammarclj/s

(get-in-grammar grammar path)

Get the a grammar node for the given path in grammar. Nil is returned if the path does not exist in the grammar, the tag type along the path don't match, or the numeric parser index is out-of-bounds. Like get-in for grammars.

Get the a grammar node for the given path in grammar. Nil is
returned if the path does not exist in the grammar, the tag type
along the path don't match, or the numeric parser index is
out-of-bounds. Like get-in for grammars.
raw docstring

get-weighted-ancestorsclj/s

(get-weighted-ancestors grammar path)

grammar->ebnfclj/s

(grammar->ebnf grammar)

Takes a grammar and returns the EBNF string equivalent of that grammar.

Takes a grammar and returns the EBNF string equivalent of that
grammar.
raw docstring

grammar->parserclj/s

(grammar->parser grammar & [start])

Takes a grammar and returns a instaparse parser. The start production must either be set on the grammar metadata (by parser->grammar) or must be explicitly provided.

Takes a grammar and returns a instaparse parser. The start
production must either be set on the grammar metadata (by
parser->grammar) or must be explicitly provided.
raw docstring

LEAF-TAGSclj/s


load-grammarclj/s

(load-grammar ebnf)

Takes an EBNF grammar test string and returns an instacheck grammar (via parser->grammar).

Takes an EBNF grammar test string and returns an instacheck
grammar (via parser->grammar).
raw docstring

load-parserclj/s

(load-parser ebnf)

Takes an EBNF grammar test string and returns an instacheck parser.

Takes an EBNF grammar test string and returns an instacheck
parser.
raw docstring

memoized-paths-to-leafclj/s


NIL-EDGEclj/s


ntrekclj/s

(ntrek grammar)

Return a ntrek (node trek) of the grammar (map of paths to leaf nodes).

Return a ntrek (node trek) of the grammar (map of paths to leaf
nodes).
raw docstring

ntrek->grammarclj/s

(ntrek->grammar ntrek)

Take an ntrek (node trek) and convert it back into a grammar

Take an ntrek (node trek) and convert it back into a grammar
raw docstring

parser->grammarclj/s

(parser->grammar parser)

Takes a instaparse parser and returns an instacheck grammar: the :grammar value from the parser with a metadata map containing the start rule (:start).

Takes a instaparse parser and returns an instacheck grammar: the
:grammar value from the parser with a metadata map containing the
start rule (:start).
raw docstring

paths-to-leafclj/s

(paths-to-leaf grammar leaf-val)

Given a grammar and a non-terminal keyword nt, return all paths within the grammar that have nt as a leaf node.

Given a grammar and a non-terminal keyword nt, return all paths
within the grammar that have nt as a leaf node.
raw docstring

TERMINALclj/s

(TERMINAL v)

TERMINAL-TAGSclj/s


trekclj/s

(trek grammar)

Return a trek (value trek) of the grammar (map of paths to node values).

Return a trek (value trek) of the grammar (map of paths to node
values).
raw docstring

trek->grammarclj/s

(trek->grammar trek)

Take a trek (value trek) and convert it back into a grammar

Take a trek (value trek) and convert it back into a grammar
raw docstring

trek-grammarclj/s

(trek-grammar grammar tx)

Walk a grammar graph applying tx at each path/node

Walk a grammar graph applying tx at each path/node
raw docstring

update-in-grammarclj/s

(update-in-grammar grammar [rule-kw & rest-path :as path] f & args)

Update a grammar node at the given path in the grammar by running (apply f node args) on the node and returning the update grammar. Like update-in for grammars.

Update a grammar node at the given path in the grammar by running
(apply f node args) on the node and returning the update grammar.
Like update-in for grammars.
raw docstring

walk-grammarclj/s

(walk-grammar grammar f)

Breadth-first walk a grammar transforming it by applying f at each path/node

Breadth-first walk a grammar transforming it by applying f at each
path/node
raw docstring

walk-grammar*clj/s

(walk-grammar* node path f)

Internal: Breadth-first walk a grammar tree transforming it by applying f at each path/node

Internal: Breadth-first walk a grammar tree transforming it by
applying f at each path/node
raw docstring

walk-grammar-ruleclj/s

(walk-grammar-rule tree rule f)

Breadth-first walk a grammar rule transforming it by applying f at each path/node

Breadth-first walk a grammar rule transforming it by applying f at
each path/node
raw docstring

WEIGHTEDclj/s

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close