1 ;;; wisent-calc.wy --- Grammar of the infix notation calculator
3 ;; Copyright (C) 2002, 2003 David Ponce
5 ;; Author: David Ponce <david@dponce.com>
6 ;; Maintainer: David Ponce <david@dponce.com>
7 ;; Created: 19 Feb 2002
9 ;; X-RCS: $Id: wisent-calc.wy,v 1.1 2007-11-26 15:12:29 michaels Exp $
11 ;; This file is not part of GNU Emacs.
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 ;; General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with this program; see the file COPYING. If not, write to
25 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
30 ;; This is a port of the Bison 1.28d Infix Calc sample program to the
31 ;; Elisp LALR parser Wisent. It illustrates usage of operator
32 ;; precedence and contextual precedence. Implementation is in the
33 ;; file wisent-calc.el.
38 ;;%package wisent-calc-wy
42 %nonassoc '=' ;; comparison
45 %left NEG ;; negation--unary minus
46 %right '^' ;; exponentiation
53 (format "%s %s" $1 $2)
88 (defun wisent-calc-setup-parser ()
89 "Setup buffer for parse."
90 (wisent-calc-wy--install-parser)
91 (setq semantic-number-expression
92 (concat "\\([0-9]+\\([.][0-9]*\\)?\\([eE][-+]?[0-9]+\\)?"
93 "\\|[.][0-9]+\\([eE][-+]?[0-9]+\\)?\\)")
94 semantic-lex-analyzer 'wisent-calc-lexer
95 semantic-lex-depth nil
96 semantic-lex-syntax-modifications
97 '((?\; ".") (?\= ".") (?\+ ".")
98 (?\- ".") (?\* ".") (?\/ ".")
99 (?\^ ".") (?\( ".") (?\) ".")
104 ;;; wisent-calc.wy ends here