/[emacs]/emacs/lisp/calc/calc-aent.el
ViewVC logotype

Diff of /emacs/lisp/calc/calc-aent.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.18 by jpb, Tue Nov 30 16:59:39 2004 UTC revision 1.19 by jpb, Wed Dec 8 06:09:20 2004 UTC
# Line 465  T means abort and give an error message. Line 465  T means abort and give an error message.
465    
466  ;;; Algebraic expression parsing.   [Public]  ;;; Algebraic expression parsing.   [Public]
467    
468    (defvar math-read-replacement-list
469      '(;; Misc symbols
470        ("±" "+/-")  ; plus or minus
471        ("×" "*")    ; multiplication sign
472        ("÷" ":")    ; division sign
473        ("−" "-")    ; subtraction sign
474        ("∕" "/")    ; division sign
475        ("∗" "*")    ; asterisk multiplication
476        ("∞" "inf")  ; infinity symbol
477        ("≤" "<=")
478        ("≥" ">=")
479        ("≦" "<=")
480        ("≧" ">=")
481        ;; fractions
482        ("¼" "(1:4)") ; 1/4
483        ("½" "(1:2)") ; 1/2
484        ("¾" "(3:4)") ; 3/4
485        ("⅓" "(1:3)") ; 1/3
486        ("⅔" "(2:3)") ; 2/3
487        ("⅕" "(1:5)") ; 1/5
488        ("⅖" "(2:5)") ; 2/5
489        ("⅗" "(3:5)") ; 3/5
490        ("⅘" "(4:5)") ; 4/5
491        ("⅙" "(1:6)") ; 1/6
492        ("⅚" "(5:6)") ; 5/6
493        ("⅛" "(1:8)") ; 1/8
494        ("⅜" "(3:8)") ; 3/8
495        ("⅝" "(5:8)") ; 5/8
496        ("⅞" "(7:8)") ; 7/8
497        ("⅟" "1:")    ; 1/...
498        ;; superscripts
499        ("⁰" "0")  ; 0
500        ("¹" "1")  ; 1
501        ("²" "2")  ; 2
502        ("³" "3")  ; 3
503        ("⁴" "4")  ; 4
504        ("⁵" "5")  ; 5
505        ("⁶" "6")  ; 6
506        ("⁷" "7")  ; 7
507        ("⁸" "8")  ; 8
508        ("⁹" "9")  ; 9
509        ("⁺" "+")  ; +
510        ("⁻" "-")  ; -
511        ("⁽" "(")  ; (
512        ("⁾" ")")  ; )
513        ("ⁿ" "n")  ; n
514        ("ⁱ" "i")) ; i
515      "A list whose elements (old new) indicate replacements to make
516    in Calc algebraic input.")
517    
518    (defvar math-read-superscripts
519      "⁰¹²³⁴⁵⁶⁷⁸⁹⁺⁻⁽⁾ⁿⁱ" ; 0123456789+-()ni
520      "A string consisting of the superscripts allowed by Calc.")
521    
522    (defun math-read-preprocess-string (str)
523      "Replace some substrings of STR by Calc equivalents."
524      (setq str
525            (replace-regexp-in-string (concat "[" math-read-superscripts "]+")
526                                      "^(\\&)" str))
527      (let ((rep-list math-read-replacement-list))
528        (while rep-list
529          (setq str
530                (replace-regexp-in-string (nth 0 (car rep-list))
531                                          (nth 1 (car rep-list)) str))
532          (setq rep-list (cdr rep-list))))
533      str)
534    
535  ;; The next few variables are local to math-read-exprs (and math-read-expr  ;; The next few variables are local to math-read-exprs (and math-read-expr
536  ;; in calc-ext.el), but are set in functions they call.  ;; in calc-ext.el), but are set in functions they call.
537    

Legend:
Removed from v.1.18  
changed lines
  Added in v.1.19

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26