Liking cljdoc? Tell your friends :D

instaparse.core


*default-input-format*clj/s


*default-output-format*clj/s


add-line-and-column-info-to-metadataclj/s≠

clj
(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:

:instaparse.gll/start-line, :instaparse.gll/start-column, :instaparse.gll/end-line, :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:
 
:instaparse.gll/start-line, :instaparse.gll/start-column,
:instaparse.gll/end-line, :instaparse.gll/end-column

The start is inclusive, the end is exclusive. Lines and columns are 1-based.
cljs
raw docstring

defparsercljmacro

(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:

  • :instaparse.abnf/case-insensitive true
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`:
- :instaparse.abnf/case-insensitive true
raw docstring

disable-tracing!clj

(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.
raw docstring

enable-tracing!clj/s≠

clj
(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.
cljs
raw docstring

failure?clj/s

(failure? result)

Tests whether a parse result is a failure.

Tests whether a parse result is a failure.
raw docstring

get-failureclj/s

(get-failure result)

Extracts failure object from failed parse result.

Extracts failure object from failed parse result.
raw docstring

parseclj/s

(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)
raw docstring

parserclj/s

(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.)
raw docstring

Parsercljs


parsesclj/s

(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)
raw docstring

set-default-input-format!clj/s

(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
raw docstring

set-default-output-format!clj/s

(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
raw docstring

spanclj/s≠

clj
(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.
cljs
raw docstring

transformclj/s≠

clj
(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)}
cljs
raw docstring

visualizeclj

(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.
raw docstring

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

× close