(add-line-and-column-info-to-metadata text parse-tree)
Given a string text
and a parse-tree
for text, return parse tree
with its metadata annotated with line and column info. The info can
then be found in the metadata map under the keywords:
:cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/start-line, :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/start-column, :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/end-line, :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/end-column
The start is inclusive, the end is exclusive. Lines and columns are 1-based.
Given a string `text` and a `parse-tree` for text, return parse tree with its metadata annotated with line and column info. The info can then be found in the metadata map under the keywords: :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/start-line, :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/start-column, :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/end-line, :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.gll/end-column The start is inclusive, the end is exclusive. Lines and columns are 1-based.
(defparser name grammar & {:as opts})
Takes a string specification of a context-free grammar, or a string URI for a text file containing such a specification, or a map/vector of parser combinators, and sets a variable to a parser for that grammar.
String specifications are processed at macro-time, not runtime, so this is an appealing alternative to (def _ (parser "...")) for ClojureScript users.
Optional keyword arguments unique to defparser
:
Takes a string specification of a context-free grammar, or a string URI for a text file containing such a specification, or a map/vector of parser combinators, and sets a variable to a parser for that grammar. String specifications are processed at macro-time, not runtime, so this is an appealing alternative to (def _ (parser "...")) for ClojureScript users. Optional keyword arguments unique to `defparser`: - :cider.nrepl.inlined.deps.instaparse.v1v4v12.instaparse.abnf/case-insensitive true
(disable-tracing!)
Recompiles instaparse with tracing disabled. Call this to restore regular performance characteristics, eliminating the small performance hit imposed by tracing.
Recompiles instaparse with tracing disabled. Call this to restore regular performance characteristics, eliminating the small performance hit imposed by tracing.
(enable-tracing!)
Recompiles instaparse with tracing enabled.
This is called implicitly the first time you invoke a parser with
:trace true
so usually you will not need to call this directly.
Recompiles instaparse with tracing enabled. This is called implicitly the first time you invoke a parser with `:trace true` so usually you will not need to call this directly.
(failure? result)
Tests whether a parse result is a failure.
Tests whether a parse result is a failure.
(get-failure result)
Extracts failure object from failed parse result.
Extracts failure object from failed parse result.
(parse parser text & {:as options})
Use parser to parse the text. Returns first parse tree found that completely parses the text. If no parse tree is possible, returns a Failure object.
Optional keyword arguments: :start :keyword (where :keyword is name of starting production rule) :partial true (parses that don't consume the whole string are okay) :total true (if parse fails, embed failure node in tree) :unhide <:tags or :content or :all> (for this parse, disable hiding) :optimize :memory (when possible, employ strategy to use less memory)
Clj only: :trace true (print diagnostic trace while parsing)
Use parser to parse the text. Returns first parse tree found that completely parses the text. If no parse tree is possible, returns a Failure object. Optional keyword arguments: :start :keyword (where :keyword is name of starting production rule) :partial true (parses that don't consume the whole string are okay) :total true (if parse fails, embed failure node in tree) :unhide <:tags or :content or :all> (for this parse, disable hiding) :optimize :memory (when possible, employ strategy to use less memory) Clj only: :trace true (print diagnostic trace while parsing)
(parser grammar-specification & {:as options})
Takes a string specification of a context-free grammar, or a URI for a text file containing such a specification (Clj only), or a map of parser combinators and returns a parser for that grammar.
Optional keyword arguments: :input-format :ebnf or :input-format :abnf
:output-format :enlive or :output-format :hiccup
:start :keyword (where :keyword is name of starting production rule)
:string-ci true (treat all string literals as case insensitive)
:auto-whitespace (:standard or :comma) or :auto-whitespace custom-whitespace-parser
Clj only: :no-slurp true (disables use of slurp to auto-detect whether input is a URI. When using this option, input must be a grammar string or grammar map. Useful for platforms where slurp is slow or not available.)
Takes a string specification of a context-free grammar, or a URI for a text file containing such a specification (Clj only), or a map of parser combinators and returns a parser for that grammar. Optional keyword arguments: :input-format :ebnf or :input-format :abnf :output-format :enlive or :output-format :hiccup :start :keyword (where :keyword is name of starting production rule) :string-ci true (treat all string literals as case insensitive) :auto-whitespace (:standard or :comma) or :auto-whitespace custom-whitespace-parser Clj only: :no-slurp true (disables use of slurp to auto-detect whether input is a URI. When using this option, input must be a grammar string or grammar map. Useful for platforms where slurp is slow or not available.)
(parses parser text & {:as options})
Use parser to parse the text. Returns lazy seq of all parse trees that completely parse the text. If no parse tree is possible, returns () with a Failure object attached as metadata.
Optional keyword arguments: :start :keyword (where :keyword is name of starting production rule) :partial true (parses that don't consume the whole string are okay) :total true (if parse fails, embed failure node in tree) :unhide <:tags or :content or :all> (for this parse, disable hiding)
Clj only: :trace true (print diagnostic trace while parsing)
Use parser to parse the text. Returns lazy seq of all parse trees that completely parse the text. If no parse tree is possible, returns () with a Failure object attached as metadata. Optional keyword arguments: :start :keyword (where :keyword is name of starting production rule) :partial true (parses that don't consume the whole string are okay) :total true (if parse fails, embed failure node in tree) :unhide <:tags or :content or :all> (for this parse, disable hiding) Clj only: :trace true (print diagnostic trace while parsing)
(set-default-input-format! type)
Changes the default input format. Input should be :abnf or :ebnf
Changes the default input format. Input should be :abnf or :ebnf
(set-default-output-format! type)
Changes the default output format. Input should be :hiccup or :enlive
Changes the default output format. Input should be :hiccup or :enlive
(span tree)
Takes a subtree of the parse tree and returns a [start-index end-index] pair indicating the span of text parsed by this subtree. start-index is inclusive and end-index is exclusive, as is customary with substrings. Returns nil if no span metadata is attached.
Takes a subtree of the parse tree and returns a [start-index end-index] pair indicating the span of text parsed by this subtree. start-index is inclusive and end-index is exclusive, as is customary with substrings. Returns nil if no span metadata is attached.
(transform transform-map parse-tree)
Takes a transform map and a parse tree (or seq of parse-trees). A transform map is a mapping from tags to functions that take a node's contents and return a replacement for the node, i.e., {:node-tag (fn [child1 child2 ...] node-replacement), :another-node-tag (fn [child1 child2 ...] node-replacement)}
Takes a transform map and a parse tree (or seq of parse-trees). A transform map is a mapping from tags to functions that take a node's contents and return a replacement for the node, i.e., {:node-tag (fn [child1 child2 ...] node-replacement), :another-node-tag (fn [child1 child2 ...] node-replacement)}
(visualize tree & {output-file :output-file options :options})
Creates a graphviz visualization of the parse tree. Optional keyword arguments: :output-file :buffered-image (return a java.awt.image.BufferedImage object) or :output-file output-file (will save the tree image to output-file)
:options options (options passed along to rhizome)
Important: This function will only work if you have added rhizome
to your dependencies, and installed graphviz on your system.
See https://github.com/ztellman/rhizome for more information.
Creates a graphviz visualization of the parse tree. Optional keyword arguments: :output-file :buffered-image (return a java.awt.image.BufferedImage object) or :output-file output-file (will save the tree image to output-file) :options options (options passed along to rhizome) Important: This function will only work if you have added rhizome to your dependencies, and installed graphviz on your system. See https://github.com/ztellman/rhizome for more information.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close