Initial Commit
[packages] / xemacs-packages / cogre / wisent-dot-wy.el
1 ;;; wisent-dot-wy.el --- Generated parser support file
2
3 ;; Copyright (C) 2003, 2004 Eric M. Ludlam
4
5 ;; Author: Eric M. Ludlam <zappo@projectile.siege-engine.com>
6 ;; Created: 2007-06-05 21:48:08-0400
7 ;; Keywords: syntax
8 ;; X-RCS: $Id: wisent-dot-wy.el,v 1.1 2007-11-26 15:04:26 michaels Exp $
9
10 ;; This file is not part of GNU Emacs.
11 ;;
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.
16 ;;
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.
21 ;;
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.
26
27 ;;; Commentary:
28 ;;
29 ;; PLEASE DO NOT MANUALLY EDIT THIS FILE!  It is automatically
30 ;; generated from the grammar file wisent-dot.wy.
31
32 ;;; History:
33 ;;
34
35 ;;; Code:
36 \f
37 ;;; Prologue
38 ;;
39 \f
40 ;;; Declarations
41 ;;
42 (defconst wisent-dot-wy--keyword-table
43   (semantic-lex-make-keyword-table
44    '(("digraph" . DIGRAPH)
45      ("graph" . GRAPH)
46      ("subgraph" . SUBGRAPH)
47      ("node" . NODE)
48      ("shape" . SHAPE)
49      ("label" . LABEL)
50      ("color" . COLOR)
51      ("style" . STYLE)
52      ("len" . LEN)
53      ("fontname" . FONTNAME)
54      ("fontsize" . FONTSIZE)
55      ("width" . WIDTH)
56      ("height" . HEIGHT)
57      ("splines" . SPLINES)
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.")
71
72 (defconst wisent-dot-wy--token-table
73   (semantic-lex-make-type-table
74    '(("number"
75       (number))
76      ("string"
77       (string))
78      ("symbol"
79       (symbol))
80      ("close-paren"
81       (RPAREN . ")")
82       (RBRACKET . "]")
83       (RBRACE . "}"))
84      ("open-paren"
85       (LPAREN . "(")
86       (LBRACKET . "[")
87       (LBRACE . "{"))
88      ("block"
89       (PAREN_BLOCK . "(LPAREN RPAREN)")
90       (BRACE_BLOCK . "(LBRACE RBRACE)")
91       (BRACKET_BLOCK . "(LBRACKET RBRACKET)"))
92      ("punctuation"
93       (COMMA . ",")
94       (SEMI . ";")
95       (EQUAL . "=")
96       (LINK . "--")
97       (DILINK . "->")))
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.")
106
107 (defconst wisent-dot-wy--parse-table
108   (progn
109     (eval-when-compile
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)
113        nil
114        (dot_file
115         ((digraph))
116         ((graph)))
117        (digraph
118         ((DIGRAPH symbol BRACE_BLOCK)
119          (wisent-raw-tag
120           (semantic-tag $2 'digraph :members
121                         (semantic-parse-region
122                          (car $region3)
123                          (cdr $region3)
124                          'graph-contents 1)))))
125        (graph
126         ((GRAPH symbol BRACE_BLOCK)
127          (wisent-raw-tag
128           (semantic-tag $2 'graph :members
129                         (semantic-parse-region
130                          (car $region3)
131                          (cdr $region3)
132                          'graph-contents 1)))))
133        (graph-contents
134         ((LBRACE)
135          nil)
136         ((RBRACE)
137          nil)
138         ((label))
139         ((style))
140         ((graph-attributes))
141         ((subgraph))
142         ((node))
143         ((named-node))
144         ((links)))
145        (label
146         ((LABEL EQUAL string SEMI)
147          (wisent-raw-tag
148           (semantic-tag $3 'label))))
149        (style
150         ((STYLE EQUAL symbol SEMI)
151          (wisent-raw-tag
152           (semantic-tag $3 'style))))
153        (subgraph
154         ((SUBGRAPH symbol BRACE_BLOCK)
155          (wisent-raw-tag
156           (semantic-tag $2 'graph :members
157                         (semantic-parse-region
158                          (car $region3)
159                          (cdr $region3)
160                          'graph-contents 1)))))
161        (node
162         ((NODE BRACKET_BLOCK SEMI)
163          (wisent-raw-tag
164           (semantic-tag "NODE" 'generic-node :attributes
165                         (semantic-parse-region
166                          (car $region2)
167                          (cdr $region2)
168                          'node-description 1)))))
169        (graph-attributes
170         ((GRAPH BRACKET_BLOCK SEMI)
171          (wisent-raw-tag
172           (semantic-tag "GRAPH" 'graph-attributes :attributes
173                         (semantic-parse-region
174                          (car $region2)
175                          (cdr $region2)
176                          'node-description 1)))))
177        (named-node
178         ((symbol BRACKET_BLOCK SEMI)
179          (wisent-raw-tag
180           (semantic-tag $1 'node :attributes
181                         (semantic-parse-region
182                          (car $region2)
183                          (cdr $region2)
184                          'node-description 1)))))
185        (node-description
186         ((LBRACKET)
187          nil)
188         ((RBRACKET)
189          nil)
190         ((COMMA)
191          nil)
192         ((SHAPE EQUAL symbol)
193          (wisent-raw-tag
194           (semantic-tag $1 'attribute :value $3)))
195         ((LABEL EQUAL string)
196          (wisent-raw-tag
197           (semantic-tag $1 'attribute :value $3)))
198         ((FONTNAME EQUAL string)
199          (wisent-raw-tag
200           (semantic-tag $1 'attribute :value $3)))
201         ((FONTSIZE EQUAL number)
202          (wisent-raw-tag
203           (semantic-tag $1 'attribute :value $3)))
204         ((symbol EQUAL symbol)
205          (wisent-raw-tag
206           (semantic-tag $1 'attribute :value $3))))
207        (links
208         ((symbol DILINK symbol opt-link-attributes opt-semi)
209          (wisent-raw-tag
210           (semantic-tag $1 'link :to $3 :attributes $4)))
211         ((BRACE_BLOCK)))
212        (opt-semi
213         ((SEMI)
214          nil)
215         (nil))
216        (opt-link-attributes
217         ((BRACKET_BLOCK)
218          (semantic-parse-region
219           (car $region1)
220           (cdr $region1)
221           'node-description 1))
222         (nil)))
223      '(dot_file graph-contents node-description)))
224   "Parser table.")
225
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))
239
240 \f
241 ;;; Analyzers
242 ;;
243 (require 'semantic-lex)
244
245 (define-lex-keyword-type-analyzer wisent-dot-wy--<keyword>-keyword-analyzer
246   "keyword analyzer for <keyword> tokens."
247   "\\(\\sw\\|\\s_\\)+")
248
249 (define-lex-block-type-analyzer wisent-dot-wy--<block>-block-analyzer
250   "block analyzer for <block> tokens."
251   "\\s(\\|\\s)"
252   '((("[" LBRACKET BRACKET_BLOCK)
253      ("{" LBRACE BRACE_BLOCK)
254      ("(" LPAREN PAREN_BLOCK))
255     ("]" RBRACKET)
256     ("}" RBRACE)
257     (")" RPAREN))
258   )
259
260 (define-lex-regex-type-analyzer wisent-dot-wy--<symbol>-regexp-analyzer
261   "regexp analyzer for <symbol> tokens."
262   "\\(\\sw\\|\\s_\\)+"
263   nil
264   'symbol)
265
266 (define-lex-sexp-type-analyzer wisent-dot-wy--<string>-sexp-analyzer
267   "sexp analyzer for <string> tokens."
268   "\\s\""
269   'string)
270
271 (define-lex-regex-type-analyzer wisent-dot-wy--<number>-regexp-analyzer
272   "regexp analyzer for <number> tokens."
273   semantic-lex-number-expression
274   nil
275   'number)
276
277 (define-lex-string-type-analyzer wisent-dot-wy--<punctuation>-string-analyzer
278   "string analyzer for <punctuation> tokens."
279   "\\s.+"
280   '((COMMA . ",")
281     (SEMI . ";")
282     (EQUAL . "=")
283     (LINK . "--")
284     (DILINK . "->"))
285   'punctuation)
286
287 \f
288 ;;; Epilogue
289 ;;
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
304   )
305
306 (provide 'wisent-dot-wy)
307
308 ;;; wisent-dot-wy.el ends here