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.
sourceraw 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.
sourceraw docstring

CHILD-EDGEclj/s

(CHILD-EDGE e)
source

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).
sourceraw 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.
sourceraw 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.
sourceraw 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 %)))
sourceraw docstring

get-ancestors*clj/s

(get-ancestors* grammar path pred avoid)
source

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.
sourceraw docstring

get-descendants*clj/s

(get-descendants* grammar path pred avoid)
source

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.
sourceraw docstring

get-weighted-ancestorsclj/s

(get-weighted-ancestors grammar path)
source

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.
sourceraw 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.
sourceraw docstring

LEAF-TAGSclj/s

source

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).
sourceraw 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.
sourceraw docstring

memoized-paths-to-leafclj/s

source

NIL-EDGEclj/s

source

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).
sourceraw 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
sourceraw 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).
sourceraw 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.
sourceraw docstring

TERMINALclj/s

(TERMINAL v)
source

TERMINAL-TAGSclj/s

source

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).
sourceraw 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
sourceraw 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
sourceraw 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.
sourceraw 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
sourceraw 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
sourceraw 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
sourceraw docstring

WEIGHTEDclj/s

source

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

× close