               (message "TODO handling error here"))))))))
 
 
+
+(defstruct antlr-parser
+  "An Antlr parser"
+  name
+  (token-names nil)
+  (tokens (make-hash-table))
+  (rules (make-hash-table))
+  (bitsets (make-hash-table))
+)
+
+(defmacro with-parser (name &rest body)
+  `(progn 
+     (let ((current-parser (gethash ',name *antlr-runtime-parsers*)))
+       ,@body)))
+
+(defun parser-token-names (&rest names)
+  (setf (antlr-parser-token-names current-parser) names))
+
+(defmacro parser-initialization (&rest body))
+
+(defmacro parser-bitset (name bitsets)
+  `(puthash ',name 
+            (create-bitset ',bitsets)
+            (antlr-parser-bitsets current-parser)))
+
+(defstruct bitset
+  "An Antlr bitset"
+  bits)
+
+(defun create-bitset (bitsets)
+  (make-bitset :bits bitsets))
+
 (provide 'antlr-runtime)
 ;;; antlr-runtime.el ends here

(defvar *antlr-runtime-lexers* (make-hash-table)
  "Keeps track of all lexers defined in the system, including their definitions") 

(defconst *antlr-token-default-channel* 0)
(defconst *antlr-token-invalid-token-type* 0)


  `(puthash ',name 
            (make-antlr-lexer :name ',name) 
            *antlr-runtime-lexers*))

(defmacro defparser (name)
  `(puthash ',name 
            (make-antlr-parser :name ',name) 
            *antlr-runtime-parsers*))

(defstruct antlr-lexer
  "An Antlr lexer"
