CrossClj

1.4.5 docs

SourceDocs



RECENT
    VARS
    *default-input-format*
    *default-output-format*
    ->Parser
    add-line-and-column-info-to-metadata
    defparser
    disable-tracing!
    enable-tracing!
    failure?
    get-failure
    map->Parser
    parse
    parser
    parses
    set-default-input-format!
    set-default-output-format!
    span
    standard-whitespace-parsers
    transform
    unhide-parser
    visualize

    « Index of all namespaces of this project

    (->Parser grammar start-production output-format)
    Positional factory function for class instaparse.core.Parser.
    
    macro
    (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
    (disable-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.
    (failure? result)
    Tests whether a parse result is a failure.
    
    (get-failure result)
    Extracts failure object from failed parse result.
    
    (map->Parser m__8593__auto__)
    Factory function for class instaparse.core.Parser, taking a map of keywords to field values.
    
    (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)
    (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.)
    (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)
    (set-default-input-format! type)
    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
    
    (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.
    (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)}
    Private
    (unhide-parser parser unhide)
    (visualize tree & {output-file :output-file, options :options})
    Creates a graphviz visualization of the parse tree.
       Optional keyword arguments:
       :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.