File: viz.cljs

package info (click to toggle)
instaparse-clojure 1.4.7-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 536 kB
  • ctags: 3
  • sloc: xml: 124; makefile: 23
file content (15 lines) | stat: -rw-r--r-- 461 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
(ns instaparse.viz)   

(defn span
  "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."
  [tree]
  (let [m (meta tree)
        s (:instaparse.gll/start-index m)
        e (:instaparse.gll/end-index m)]
    (when (and s e)
      [s e])))