Liking cljdoc? Tell your friends :D

instacheck.reduce


prune-grammarclj

(prune-grammar grammar {:keys [wtrek start removed] :as ctx})

Takes a grammar and returns a pruned grammar based on keys specified in the options map. Three different prune operations are performed:

  • Removes rules listed in :removed
  • Prune rule bodies/productions based on :wtrek
  • If :start is specified in the options or is on the meta of the grammar, then rules are removed that cannot be reached (directly or indirectly) from the start rule/production..
Takes a grammar and returns a pruned grammar based on keys
specified in the options map. Three different prune operations are
performed:
  - Removes rules listed in :removed
  - Prune rule bodies/productions based on :wtrek
  - If :start is specified in the options or is on the meta of the
    grammar, then rules are removed that cannot be reached (directly
    or indirectly) from the start rule/production..
sourceraw docstring

prune-node*clj

(prune-node* node wtrek cur-path)

Internal: Used by prune-node* to prune rule bodies/productions based on :wtrek

Internal: Used by prune-node* to prune rule bodies/productions
based on :wtrek
sourceraw docstring

reduce-weightsclj

(reduce-weights grammar wtrek)

Takes a grammar and wtrek and returns a context map with a :wtrek map and a :removed set that describe the removed edges and nodes respectively. Any zero weights in the :wtrek map represent a node edge that has been removed. Any nodes in the :removed set represent root NTs nodes that have been removed.

A weighted node (:alt, :ord, :opt, or :star) with all child edges is a node that has been removed. For each removed node, parent-search is called to propagate the removal upwards in the tree to nearest weighted parent edge or root NT. If a weighted parent edge is found then that edge weight is set to zero. If all siblings of the edge also have a zero weight then the parent node is add to the pending remove set. If no weighted parent is found (if there are no other weighted nodes between the current node and the root) and the search reaches a root NT node then that root NT is added to the pending remove set.

The propagation of node removals continues until there are no more pending node to remove. The call to parent-search may add more nodes to be removed but already removed nodes will not be added again so the process will eventually terminate.

Takes a grammar and wtrek and returns a context map with a :wtrek
map and a :removed set that describe the removed edges and nodes
respectively. Any zero weights in the :wtrek map represent a node
edge that has been removed. Any nodes in the :removed set represent
root NTs nodes that have been removed.

A weighted node (:alt, :ord, :opt, or :star) with all child edges is
a node that has been removed. For each removed node, parent-search
is called to propagate the removal upwards in the tree to nearest
weighted parent edge or root NT. If a weighted parent edge is found
then that edge weight is set to zero. If all siblings of the edge
also have a zero weight then the parent node is add to the pending
remove set. If no weighted parent is found (if there are no other
weighted nodes between the current node and the root) and the search
reaches a root NT node then that root NT is added to the pending
remove set.

The propagation of node removals continues until there are no more
pending node to remove. The call to parent-search may add more nodes
to be removed but already removed nodes will not be added again so
the process will eventually terminate.
sourceraw docstring

reduce-wtrek-with-weightsclj

(reduce-wtrek-with-weights wtrek weights-to-reduce reducer-fn)

Takes a wtrek, a weights-to-reduce map and a reducer-fn. For each path in weights-to-reduce, the reducer-fn is called with the weights for that path from wtrek and weights-to-reduce respectively. Based on those two values the reducer-fn should return a new value to be updated in the wtrek.

Typically the output from this will then be used with the reduce-weights function to propogate any nodes removed by the reduction process: (reduce-weights grammar (reduce-wtrek-with-weights wtrek weights-to-reduce reducer-fn))

Takes a wtrek, a weights-to-reduce map and a reducer-fn. For each
path in weights-to-reduce, the reducer-fn is called with the weights
for that path from wtrek and weights-to-reduce respectively. Based
on those two values the reducer-fn should return a new value to be
updated in the wtrek.

Typically the output from this will then be used with the
reduce-weights function to propogate any nodes removed by the
reduction process:
  (reduce-weights grammar (reduce-wtrek-with-weights
                            wtrek weights-to-reduce reducer-fn))
sourceraw docstring

reducer-halfclj

(reducer-half start-weight parsed-weight)

Ignores parsed-weight. Returns start-weight divided in two and rounded down.

Ignores parsed-weight. Returns start-weight divided in two and
rounded down.
sourceraw docstring

reducer-ladderclj

(reducer-ladder seq-ladder start-weight parsed-weight)

Ignores parsed-weight. Returns the next weight in seq-ladder that is lower than start-weight. Designed to be used as a partial like this: (partial reducer-ladder [30 10 3 1]) The values in the ladder will be sorted in descending order and an implicit zero is added to the end.

Ignores parsed-weight. Returns the next weight in seq-ladder that
is lower than start-weight. Designed to be used as a partial like this:
  (partial reducer-ladder [30 10 3 1])
The values in the ladder will be sorted in descending order and an
implicit zero is added to the end.
sourceraw docstring

reducer-zeroclj

(reducer-zero start-weight parsed-weight)

Ignores params. Always returns 0

Ignores params. Always returns 0
sourceraw docstring

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

× close