Initial Commit
[packages] / xemacs-packages / semantic / wisent / wisent-calc-wy.el
1 ;;; wisent-calc-wy.el --- Generated parser support file
2
3 ;; Copyright (C) 2002, 2003 David Ponce
4
5 ;; Author: Eric M. Ludlam <zappo@projectile.siege-engine.com>
6 ;; Created: 2007-06-05 21:46:55-0400
7 ;; Keywords: syntax
8 ;; X-RCS: $Id: wisent-calc-wy.el,v 1.1 2007-11-26 15:12:28 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-calc.wy.
31
32 ;;; History:
33 ;;
34
35 ;;; Code:
36 \f
37 ;;; Prologue
38 ;;
39 \f
40 ;;; Declarations
41 ;;
42 (defconst wisent-calc-wy--keyword-table
43   (semantic-lex-make-keyword-table 'nil 'nil)
44   "Table of language keywords.")
45
46 (defconst wisent-calc-wy--token-table
47   (semantic-lex-make-type-table
48    '(("number"
49       (NUM)))
50    'nil)
51   "Table of lexical tokens.")
52
53 (defconst wisent-calc-wy--parse-table
54   (progn
55     (eval-when-compile
56       (require 'wisent-comp))
57     (wisent-compile-grammar
58      '((NUM)
59        ((nonassoc 61)
60         (left 45 43)
61         (left 42 47)
62         (left NEG)
63         (right 94))
64        (input
65         ((line))
66         ((input line)
67          (format "%s %s" $1 $2)))
68        (line
69         ((59)
70          (progn ";"))
71         ((exp 59)
72          (format "%s;" $1))
73         ((error 59)
74          (progn "Error;")))
75        (exp
76         ((NUM)
77          (string-to-number $1))
78         ((exp 61 exp)
79          (= $1 $3))
80         ((exp 43 exp)
81          (+ $1 $3))
82         ((exp 45 exp)
83          (- $1 $3))
84         ((exp 42 exp)
85          (* $1 $3))
86         ((exp 47 exp)
87          (/ $1 $3))
88         ((45 exp)
89          [NEG]
90          (- $2))
91         ((exp 94 exp)
92          (expt $1 $3))
93         ((40 exp 41)
94          (progn $2))))
95      'nil))
96   "Parser table.")
97
98 (defun wisent-calc-wy--install-parser ()
99   "Setup the Semantic Parser."
100   (semantic-install-function-overrides
101    '((parse-stream . wisent-parse-stream)))
102   (setq semantic-parser-name "LALR"
103         semantic--parse-table wisent-calc-wy--parse-table
104         semantic-debug-parser-source "wisent-calc.wy"
105         semantic-flex-keywords-obarray wisent-calc-wy--keyword-table
106         semantic-lex-types-obarray wisent-calc-wy--token-table)
107   ;; Collect unmatched syntax lexical tokens
108   (semantic-make-local-hook 'wisent-discarding-token-functions)
109   (add-hook 'wisent-discarding-token-functions
110             'wisent-collect-unmatched-syntax nil t))
111
112 \f
113 ;;; Analyzers
114 ;;
115 (require 'semantic-lex)
116
117 \f
118 ;;; Epilogue
119 ;;
120 (defun wisent-calc-setup-parser ()
121   "Setup buffer for parse."
122   (wisent-calc-wy--install-parser)
123   (setq semantic-number-expression
124         (concat "\\([0-9]+\\([.][0-9]*\\)?\\([eE][-+]?[0-9]+\\)?"
125                 "\\|[.][0-9]+\\([eE][-+]?[0-9]+\\)?\\)")
126         semantic-lex-analyzer 'wisent-calc-lexer
127         semantic-lex-depth nil
128         semantic-lex-syntax-modifications
129         '((?\; ".") (?\= ".") (?\+ ".")
130           (?\- ".") (?\* ".") (?\/ ".")
131           (?\^ ".") (?\( ".") (?\) ".")
132           )
133         )
134   )
135
136 (provide 'wisent-calc-wy)
137
138 ;;; wisent-calc-wy.el ends here