1 ;;; bovine-debug.el --- Debugger support for bovinator
3 ;;; Copyright (C) 2003 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
6 ;; X-RCS: $Id: bovine-debug.el,v 1.1 2007-11-26 15:11:49 michaels Exp $
8 ;; This file is not part of GNU Emacs.
10 ;; This is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; This software is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 ;; Boston, MA 02110-1301, USA.
27 ;; Implementation of the semantic debug support framework for the
31 (require 'semantic-debug)
35 ;;; Support a frame for the Bovinator
37 (defclass semantic-bovine-debug-frame (semantic-debug-frame)
38 ((nonterm :initarg :nonterm
41 "The name of the semantic nonterminal for this frame.")
45 "The index into NONTERM's rule list. 0 based.")
46 (match :initarg :match
49 "The index into NONTERM's RULE's match. 0 based..")
50 (collection :initarg :collection
53 "List of things matched so far.")
54 (lextoken :initarg :lextoken
57 "A Token created by `semantic-lex-token'.
58 This is the lexical token being matched by the parser.")
60 "Debugger frame representation for the bovinator.")
63 (defun semantic-bovine-debug-create-frame (nonterm rule match collection
65 "Create one bovine frame.
66 NONTERM is the name of a rule we are currently parsing.
67 RULE is the index into the list of rules in NONTERM.
68 MATCH is the index into the list of matches in RULE.
75 The RULE is for \"thing\" is 1.
76 The MATCH for \"thing\" is 1.
77 COLLECTION is a list of `things' that have been matched so far.
78 LEXTOKEN, is a token returned by the lexer which is being matched."
79 (let ((frame (semantic-bovine-debug-frame "frame"
83 :collection collection
85 (semantic-debug-set-frame semantic-debug-current-interface
89 (defmethod semantic-debug-frame-highlight ((frame semantic-debug-frame))
90 "Highlight one parser frame."
91 (let* ((nonterm (oref frame nonterm))
92 (pb (oref semantic-debug-current-interface parser-buffer))
93 (start (semantic-find-nonterminal-by-token 'start pb))
95 ;; Make sure we get a good rule name, and that it is a string
96 (if (and (eq nonterm 'bovine-toplevel) start)
97 (setq nonterm (semantic-tag-name (car start)))
98 (setq nonterm (symbol-name nonterm)))
100 (semantic-debug-highlight-rule semantic-debug-current-interface
104 (semantic-debug-highlight-lexical-token semantic-debug-current-interface
105 (oref frame lextoken))
108 (defmethod semantic-debug-frame-info ((frame semantic-debug-frame))
109 "Display info about this one parser frame."
110 (message "%S" (oref frame collection))
113 ;;; Lisp error thrown frame.
115 (defclass semantic-bovine-debug-error-frame (semantic-debug-frame)
116 ((condition :initarg :condition
118 "An error condition caught in an action.")
120 "Debugger frame representaion of a lisp error thrown during parsing.")
122 (defun semantic-create-bovine-debug-error-frame (condition)
123 "Create an error frame for bovine debugger.
124 Argument CONDITION is the thrown error condition."
125 (let ((frame (semantic-bovine-debug-error-frame "frame"
126 :condition condition)))
127 (semantic-debug-set-frame semantic-debug-current-interface
131 (defmethod semantic-debug-frame-highlight ((frame semantic-bovine-debug-error-frame))
132 "Highlight a frame from an action."
133 ;; How do I get the location of the action in the source buffer?
136 (defmethod semantic-debug-frame-info ((frame semantic-bovine-debug-error-frame))
137 "Display info about the error thrown."
138 (message "Error: %S" (oref frame condition)))
140 ;;; Parser support for the debugger
143 (defclass semantic-bovine-debug-parser (semantic-debug-parser)
146 "Represents a parser and its state.")
149 (provide 'bovine-debug)
151 ;;; bovine-debug.el ends here