Fix typos.
[bpt/emacs.git] / lisp / cedet / semantic / bovine / debug.el
CommitLineData
4feec2f5
CY
1;;; semantic/bovine/debug.el --- Debugger support for bovinator
2
73b0cd50 3;; Copyright (C) 2003, 2009-2011 Free Software Foundation, Inc.
4feec2f5
CY
4
5;; Author: Eric M. Ludlam <zappo@gnu.org>
6
7;; This file is part of GNU Emacs.
8
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.
13
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.
18
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/>.
21
22;;; Commentary:
23;;
24;; Implementation of the semantic debug support framework for the
25;; bovine parser.
26;;
27
28(require 'semantic/debug)
29(require 'semantic/find)
30
31;;; Code:
32
33;;; Support a frame for the Bovinator
34;;
35(defclass semantic-bovine-debug-frame (semantic-debug-frame)
36 ((nonterm :initarg :nonterm
37 :type symbol
38 :documentation
39 "The name of the semantic nonterminal for this frame.")
40 (rule :initarg :rule
41 :type number
42 :documentation
43 "The index into NONTERM's rule list. 0 based.")
44 (match :initarg :match
45 :type number
46 :documentation
47 "The index into NONTERM's RULE's match. 0 based..")
48 (collection :initarg :collection
49 :type list
50 :documentation
51 "List of things matched so far.")
52 (lextoken :initarg :lextoken
53 :type list
54 :documentation
55 "A Token created by `semantic-lex-token'.
56This is the lexical token being matched by the parser.")
57 )
58 "Debugger frame representation for the bovinator.")
59
60(defun semantic-bovine-debug-create-frame (nonterm rule match collection
61 lextoken)
62 "Create one bovine frame.
63NONTERM is the name of a rule we are currently parsing.
64RULE is the index into the list of rules in NONTERM.
65MATCH is the index into the list of matches in RULE.
66For example:
67 this: that
68 | other thing
69 | here
70 ;
71The NONTERM is THIS.
72The RULE is for \"thing\" is 1.
73The MATCH for \"thing\" is 1.
74COLLECTION is a list of `things' that have been matched so far.
75LEXTOKEN, is a token returned by the lexer which is being matched."
76 (let ((frame (semantic-bovine-debug-frame "frame"
77 :nonterm nonterm
78 :rule rule
79 :match match
80 :collection collection
81 :lextoken lextoken)))
82 (semantic-debug-set-frame semantic-debug-current-interface
83 frame)
84 frame))
85
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))
91 )
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)))
96
97 (semantic-debug-highlight-rule semantic-debug-current-interface
98 nonterm
99 (oref frame rule)
100 (oref frame match))
101 (semantic-debug-highlight-lexical-token semantic-debug-current-interface
102 (oref frame lextoken))
103 ))
104
105(defmethod semantic-debug-frame-info ((frame semantic-debug-frame))
106 "Display info about this one parser frame."
107 (message "%S" (oref frame collection))
108 )
109
110;;; Lisp error thrown frame.
111;;
112(defclass semantic-bovine-debug-error-frame (semantic-debug-frame)
113 ((condition :initarg :condition
114 :documentation
115 "An error condition caught in an action.")
116 )
cd1181db 117 "Debugger frame representation of a lisp error thrown during parsing.")
4feec2f5
CY
118
119(defun semantic-create-bovine-debug-error-frame (condition)
120 "Create an error frame for bovine debugger.
121Argument 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
125 frame)
126 frame))
127
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?
131 )
132
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)))
136
137;;; Parser support for the debugger
138;;
139(defclass semantic-bovine-debug-parser (semantic-debug-parser)
140 (
141 )
142 "Represents a parser and its state.")
143
144
145(provide 'semantic/bovine/debug)
146
147;;; semantic/bovine/debug.el ends here