Initial Commit
[packages] / xemacs-packages / cogre / wisent-dot.el
1 ;;; wisent-dot.el --- GraphViz DOT parser
2
3 ;; Copyright (C) 2003, 2004 Eric M. Ludlam
4
5 ;; Author: Eric Ludlam <zappo@gnu.org>
6 ;; Keywords: syntax
7 ;; X-RCS: $Id: wisent-dot.el,v 1.1 2007-11-26 15:04:27 michaels Exp $
8
9 ;; This file is not part of GNU Emacs.
10
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program; see the file COPYING.  If not, write to
23 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
25
26 ;;; Commentary:
27 ;;
28 ;; Parser for GraphViz DOT language.
29 ;; The language is declaritive and the whole thing is parsed.
30 ;; The result could be used as a data structure representing a graph.
31
32 ;; This depends on graphics dot mode by
33 ;;   Pieter E.J. Pareit <pieter.pareit@planetinternet.be>
34 ;;   http://users.skynet.be/ppareit/graphviz-dot-mode.el
35 ;;   with the following patch:
36 ;;
37 ;;
38 ;; *** graphviz-dot-mode.el     2003/03/23 17:14:22     1.1
39 ;; --- graphviz-dot-mode.el     2003/03/26 03:39:21
40 ;; ***************
41 ;; *** 98,103 ****
42 ;; --- 98,109 ----
43 ;;       (modify-syntax-entry ?/ ". 124b" st)
44 ;;       (modify-syntax-entry ?* ". 23" st)
45 ;;       (modify-syntax-entry ?\n "> b" st)
46 ;; +     (modify-syntax-entry ?= "." st)
47 ;; +     (modify-syntax-entry ?, "." st)
48 ;; +     (modify-syntax-entry ?\; "." st)
49 ;; +     (modify-syntax-entry ?- "." st)
50 ;; +     (modify-syntax-entry ?> "." st)
51 ;; +     (modify-syntax-entry ?< "." st)
52 ;;       st)
53 ;;     "Syntax table for `graphviz-dot-mode'.")
54 ;;   
55
56
57 ;;; Code:
58 (require 'semantic-wisent)
59 (require 'semantic)
60 (require 'wisent-dot-wy)
61
62 (define-mode-overload-implementation semantic-tag-components
63   graphviz-dot-mode (tag)
64   "Return the children of tag TAG."
65   (cond
66    ((memq (semantic-tag-class tag)
67          '(generic-node graph-attributes node link))
68     (semantic-tag-get-attribute tag :attributes)
69     )
70    ((memq (semantic-tag-class tag)
71          '(digraph graph))
72     (semantic-tag-get-attribute tag :members)
73     )))
74
75 ;;;###autoload
76 (defun wisent-dot-setup-parser ()
77   "Setup buffer for parse."
78   (wisent-dot-wy--install-parser)
79
80   (setq 
81    ;; Lexical Analysis
82    semantic-lex-analyzer 'wisent-dot-lexer
83    ;; Parsing
84    ;; Environment
85    semantic-imenu-summary-function 'semantic-format-tag-name
86    imenu-create-index-function 'semantic-create-imenu-index
87    semantic-command-separation-character ";"
88    ;; Speedbar
89    semantic-symbol->name-assoc-list
90    '((graph . "Graph")
91      (digraph . "Directed Graph")
92      (node . "Node")
93      )
94    ;; Navigation
95    senator-step-at-tag-classes '(graph digraph)
96    ))
97
98 ;;;###autoload
99 (add-hook 'graphviz-dot-mode-hook 'wisent-dot-setup-parser)
100
101 (provide 'wisent-dot)
102
103 ;;; wisent-dot.el ends here