   (:use [isla.lexer])
   (:require [clojure.string :as str]))
 
-(defn nnode [tag data]
-  {:tag tag :content data})
-
-(declare parse alternatives is-type pattern-sequence
+(declare parse alternatives is-type pattern-sequence pattern
          -root -block -expression -assignment -invocation
          -nl -integer -is -string -assignee -value -identifier)
 
 (defn parse [code]
   (-root (lex code)))
-
-(defn alternatives [input types] ;; bit round the houses
-  (vec (map (fn [t] (t input)) ;; get nodes for each matching type
-            (filter (fn [t] (not= nil (t input))) ;; get matching types
-                    types))))
-
-(defmulti is-type (fn [matcher token] (class matcher)))
-
-(defmethod is-type clojure.lang.Keyword [symbol token]
-  (= symbol token))
-
-(defmethod is-type java.util.regex.Pattern [re token]
-  (if (keyword? token)
-    false
-    (if (not= nil (re-matches re token))
-      true
-      false)))
-
 
 (defn -root [tokens]
   (nnode :root [(-block tokens [])]))

      {:expr (nnode :invocation (take 2 nodes)) :left-tokens (nthrest tokens 3)}
      nil)))

(defn pattern-sequence [tokens patterns collected]
  (if (and (> (count patterns) 0) ;; still patterns to test
           (>= (count tokens) (count patterns))) ;; enough tokens to satisfy pattern

      (nnode tag output))
    nil))

(defn nnode [tag data]
  {:tag tag :content data})
