1 ;;; wisent-dot-wy.el --- Generated parser support file
3 ;; Copyright (C) 2003, 2004 Eric M. Ludlam
5 ;; Author: Eric M. Ludlam <zappo@projectile.siege-engine.com>
6 ;; Created: 2007-06-05 21:48:08-0400
8 ;; X-RCS: $Id: wisent-dot-wy.el,v 1.1 2007-11-26 15:04:26 michaels Exp $
10 ;; This file is not part of GNU Emacs.
12 ;; This program is free software; you can redistribute it and/or
13 ;; modify it under the terms of the GNU General Public License as
14 ;; published by the Free Software Foundation; either version 2, or (at
15 ;; your option) any later version.
17 ;; This software is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 ;; Boston, MA 02110-1301, USA.
29 ;; PLEASE DO NOT MANUALLY EDIT THIS FILE! It is automatically
30 ;; generated from the grammar file wisent-dot.wy.
42 (defconst wisent-dot-wy--keyword-table
43 (semantic-lex-make-keyword-table
44 '(("digraph" . DIGRAPH)
46 ("subgraph" . SUBGRAPH)
53 ("fontname" . FONTNAME)
54 ("fontsize" . FONTSIZE)
58 ("overlap" . OVERLAP))
59 '(("fontsize" summary "fontsize=<font-size-number>")
60 ("fontname" summary "fontname=<font-spec>")
61 ("len" summary "len=<value>")
62 ("style" summary "style=<style-spec>")
63 ("color" summary "color=<color-spec>")
64 ("label" summary "label=\"string\"")
65 ("shape" summary "shape=<shape-type>")
66 ("node" summary "node [<attribute>...];")
67 ("subgraph" summary "subgraph <name> { <graph elements> ... }")
68 ("graph" summary "graph <name> { <graph elements> ... }")
69 ("digraph" summary "digraph <name> { <graph elements> ... }")))
70 "Table of language keywords.")
72 (defconst wisent-dot-wy--token-table
73 (semantic-lex-make-type-table
89 (PAREN_BLOCK . "(LPAREN RPAREN)")
90 (BRACE_BLOCK . "(LBRACE RBRACE)")
91 (BRACKET_BLOCK . "(LBRACKET RBRACKET)"))
98 '(("number" :declared t)
99 ("string" :declared t)
100 ("symbol" :declared t)
101 ("block" :declared t)
102 ("punctuation" syntax "\\s.+")
103 ("punctuation" :declared t)
104 ("keyword" :declared t)))
105 "Table of lexical tokens.")
107 (defconst wisent-dot-wy--parse-table
110 (require 'wisent-comp))
111 (wisent-compile-grammar
112 '((DIGRAPH GRAPH SUBGRAPH NODE SHAPE LABEL COLOR STYLE LEN FONTNAME FONTSIZE WIDTH HEIGHT SPLINES OVERLAP DILINK LINK EQUAL SEMI COMMA BRACKET_BLOCK BRACE_BLOCK PAREN_BLOCK LBRACE RBRACE LBRACKET RBRACKET LPAREN RPAREN symbol string number)
118 ((DIGRAPH symbol BRACE_BLOCK)
120 (semantic-tag $2 'digraph :members
121 (semantic-parse-region
124 'graph-contents 1)))))
126 ((GRAPH symbol BRACE_BLOCK)
128 (semantic-tag $2 'graph :members
129 (semantic-parse-region
132 'graph-contents 1)))))
146 ((LABEL EQUAL string SEMI)
148 (semantic-tag $3 'label))))
150 ((STYLE EQUAL symbol SEMI)
152 (semantic-tag $3 'style))))
154 ((SUBGRAPH symbol BRACE_BLOCK)
156 (semantic-tag $2 'graph :members
157 (semantic-parse-region
160 'graph-contents 1)))))
162 ((NODE BRACKET_BLOCK SEMI)
164 (semantic-tag "NODE" 'generic-node :attributes
165 (semantic-parse-region
168 'node-description 1)))))
170 ((GRAPH BRACKET_BLOCK SEMI)
172 (semantic-tag "GRAPH" 'graph-attributes :attributes
173 (semantic-parse-region
176 'node-description 1)))))
178 ((symbol BRACKET_BLOCK SEMI)
180 (semantic-tag $1 'node :attributes
181 (semantic-parse-region
184 'node-description 1)))))
192 ((SHAPE EQUAL symbol)
194 (semantic-tag $1 'attribute :value $3)))
195 ((LABEL EQUAL string)
197 (semantic-tag $1 'attribute :value $3)))
198 ((FONTNAME EQUAL string)
200 (semantic-tag $1 'attribute :value $3)))
201 ((FONTSIZE EQUAL number)
203 (semantic-tag $1 'attribute :value $3)))
204 ((symbol EQUAL symbol)
206 (semantic-tag $1 'attribute :value $3))))
208 ((symbol DILINK symbol opt-link-attributes opt-semi)
210 (semantic-tag $1 'link :to $3 :attributes $4)))
218 (semantic-parse-region
221 'node-description 1))
223 '(dot_file graph-contents node-description)))
226 (defun wisent-dot-wy--install-parser ()
227 "Setup the Semantic Parser."
228 (semantic-install-function-overrides
229 '((parse-stream . wisent-parse-stream)))
230 (setq semantic-parser-name "LALR"
231 semantic--parse-table wisent-dot-wy--parse-table
232 semantic-debug-parser-source "wisent-dot.wy"
233 semantic-flex-keywords-obarray wisent-dot-wy--keyword-table
234 semantic-lex-types-obarray wisent-dot-wy--token-table)
235 ;; Collect unmatched syntax lexical tokens
236 (semantic-make-local-hook 'wisent-discarding-token-functions)
237 (add-hook 'wisent-discarding-token-functions
238 'wisent-collect-unmatched-syntax nil t))
243 (require 'semantic-lex)
245 (define-lex-keyword-type-analyzer wisent-dot-wy--<keyword>-keyword-analyzer
246 "keyword analyzer for <keyword> tokens."
247 "\\(\\sw\\|\\s_\\)+")
249 (define-lex-block-type-analyzer wisent-dot-wy--<block>-block-analyzer
250 "block analyzer for <block> tokens."
252 '((("[" LBRACKET BRACKET_BLOCK)
253 ("{" LBRACE BRACE_BLOCK)
254 ("(" LPAREN PAREN_BLOCK))
260 (define-lex-regex-type-analyzer wisent-dot-wy--<symbol>-regexp-analyzer
261 "regexp analyzer for <symbol> tokens."
266 (define-lex-sexp-type-analyzer wisent-dot-wy--<string>-sexp-analyzer
267 "sexp analyzer for <string> tokens."
271 (define-lex-regex-type-analyzer wisent-dot-wy--<number>-regexp-analyzer
272 "regexp analyzer for <number> tokens."
273 semantic-lex-number-expression
277 (define-lex-string-type-analyzer wisent-dot-wy--<punctuation>-string-analyzer
278 "string analyzer for <punctuation> tokens."
290 (define-lex wisent-dot-lexer
291 "Lexical analyzer that handles DOT buffers.
292 It ignores whitespace, newlines and comments."
293 semantic-lex-ignore-whitespace
294 semantic-lex-ignore-newline
295 semantic-lex-ignore-comments
296 wisent-dot-wy--<keyword>-keyword-analyzer
297 wisent-dot-wy--<symbol>-regexp-analyzer
298 wisent-dot-wy--<block>-block-analyzer
299 ;; ?? semantic-lex-close-paren
300 wisent-dot-wy--<number>-regexp-analyzer
301 wisent-dot-wy--<string>-sexp-analyzer
302 wisent-dot-wy--<punctuation>-string-analyzer
303 semantic-lex-default-action
306 (provide 'wisent-dot-wy)
308 ;;; wisent-dot-wy.el ends here