1 ;;; semantic/bovine/debug.el --- Debugger support for bovinator
3 ;; Copyright (C) 2003, 2009-2011 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
24 ;; Implementation of the semantic debug support framework for the
28 (require 'semantic
/debug
)
29 (require 'semantic
/find
)
33 ;;; Support a frame for the Bovinator
35 (defclass semantic-bovine-debug-frame
(semantic-debug-frame)
36 ((nonterm :initarg
:nonterm
39 "The name of the semantic nonterminal for this frame.")
43 "The index into NONTERM's rule list. 0 based.")
44 (match :initarg
:match
47 "The index into NONTERM's RULE's match. 0 based..")
48 (collection :initarg
:collection
51 "List of things matched so far.")
52 (lextoken :initarg
:lextoken
55 "A Token created by `semantic-lex-token'.
56 This is the lexical token being matched by the parser.")
58 "Debugger frame representation for the bovinator.")
60 (defun semantic-bovine-debug-create-frame (nonterm rule match collection
62 "Create one bovine frame.
63 NONTERM is the name of a rule we are currently parsing.
64 RULE is the index into the list of rules in NONTERM.
65 MATCH is the index into the list of matches in RULE.
72 The RULE is for \"thing\" is 1.
73 The MATCH for \"thing\" is 1.
74 COLLECTION is a list of `things' that have been matched so far.
75 LEXTOKEN, is a token returned by the lexer which is being matched."
76 (let ((frame (semantic-bovine-debug-frame "frame"
80 :collection collection
82 (semantic-debug-set-frame semantic-debug-current-interface
86 (defmethod semantic-debug-frame-highlight ((frame semantic-debug-frame
))
87 "Highlight one parser frame."
88 (let* ((nonterm (oref frame nonterm
))
89 (pb (oref semantic-debug-current-interface parser-buffer
))
90 (start (semantic-brute-find-tag-by-class 'start pb
))
92 ;; Make sure we get a good rule name, and that it is a string
93 (if (and (eq nonterm
'bovine-toplevel
) start
)
94 (setq nonterm
(semantic-tag-name (car start
)))
95 (setq nonterm
(symbol-name nonterm
)))
97 (semantic-debug-highlight-rule semantic-debug-current-interface
101 (semantic-debug-highlight-lexical-token semantic-debug-current-interface
102 (oref frame lextoken
))
105 (defmethod semantic-debug-frame-info ((frame semantic-debug-frame
))
106 "Display info about this one parser frame."
107 (message "%S" (oref frame collection
))
110 ;;; Lisp error thrown frame.
112 (defclass semantic-bovine-debug-error-frame
(semantic-debug-frame)
113 ((condition :initarg
:condition
115 "An error condition caught in an action.")
117 "Debugger frame representation of a lisp error thrown during parsing.")
119 (defun semantic-create-bovine-debug-error-frame (condition)
120 "Create an error frame for bovine debugger.
121 Argument CONDITION is the thrown error condition."
122 (let ((frame (semantic-bovine-debug-error-frame "frame"
123 :condition condition
)))
124 (semantic-debug-set-frame semantic-debug-current-interface
128 (defmethod semantic-debug-frame-highlight ((frame semantic-bovine-debug-error-frame
))
129 "Highlight a frame from an action."
130 ;; How do I get the location of the action in the source buffer?
133 (defmethod semantic-debug-frame-info ((frame semantic-bovine-debug-error-frame
))
134 "Display info about the error thrown."
135 (message "Error: %S" (oref frame condition
)))
137 ;;; Parser support for the debugger
139 (defclass semantic-bovine-debug-parser
(semantic-debug-parser)
142 "Represents a parser and its state.")
145 (provide 'semantic
/bovine
/debug
)
147 ;;; semantic/bovine/debug.el ends here