1;; 2;; Copyright (c) 2003 by The XFree86 Project, Inc. 3;; 4;; Permission is hereby granted, free of charge, to any person obtaining a 5;; copy of this software and associated documentation files (the "Software"), 6;; to deal in the Software without restriction, including without limitation 7;; the rights to use, copy, modify, merge, publish, distribute, sublicense, 8;; and/or sell copies of the Software, and to permit persons to whom the 9;; Software is furnished to do so, subject to the following conditions: 10;; 11;; The above copyright notice and this permission notice shall be included in 12;; all copies or substantial portions of the Software. 13;; 14;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 18;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 19;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20;; SOFTWARE. 21;; 22;; Except as contained in this notice, the name of the XFree86 Project shall 23;; not be used in advertising or otherwise to promote the sale, use or other 24;; dealings in this Software without prior written authorization from the 25;; XFree86 Project. 26;; 27;; Author: Paulo César Pereira de Andrade 28;; 29;; 30;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/sh.lsp,v 1.1 2003/01/16 03:50:46 paulo Exp $ 31;; 32 33(require "syntax") 34(require "indent") 35(in-package "XEDIT") 36 37(defsynprop *prop-escape* 38 "escape" 39 :font "*lucidatypewriter-medium-r*-12-*" 40 :foreground "Red3") 41 42(defsynprop *prop-variable* 43 "variable" 44 :font "*lucidatypewriter-medium-r*-12-*" 45 :foreground "Gold4") 46 47(defsynprop *prop-backslash* 48 "backslash" 49 :font "*courier-bold-r*-12-*" 50 :foreground "green4") 51 52;; XXX it would be interesting if "here-documents" could be parsed 53;; just searching for "<<\s*EOF\\>" and then for "^EOF\\>" should 54;; handle most cases, but would be a hack... 55(defsyntax *sh-mode* :main nil #'default-indent nil 56 ;; keywords and common commands/builtins 57 (syntoken "\\<(if|then|elif|else|fi|case|in|esac|for|do|done|while|until|break|continue|eval|exit|exec|test|echo|cd|shift|local|return)\\>" 58 :property *prop-keyword*) 59 60 ; comments 61 (syntoken "#.*$" :property *prop-comment*) 62 63 ;; punctuation 64 (syntoken "[][;:*?(){}<>&!|$#]+" :property *prop-punctuation*) 65 66 ;; variable declaration 67 (syntoken "\\w+=" :property *prop-preprocessor*) 68 69 ;; numbers 70 (syntoken "\\<\\d+\\>" :property *prop-number*) 71 72 ;; escaped characters at toplevel 73 (syntoken "\\\\." :property *prop-backslash*) 74 75 ;; single quote 76 (syntoken "'" :nospec t :contained t :begin :single) 77 (syntable :single *prop-constant* nil 78 ;; do nothing, escaped characters 79 (syntoken "\\\\.") 80 (syntoken "'" :nospec t :switch -1) 81 ) 82 83 ;; double quote 84 (syntoken "\"" :nospec t :contained t :begin :double) 85 (syntable :double *prop-string* #'default-indent 86 ;; escaped characters 87 (syntoken "\\\\." :property *prop-backslash*) 88 (syntoken "\"" :nospec t :switch -1) 89 ;; rule to start escape 90 (syntoken "`" :nospec t :contained t :begin :escape) 91 ;; ignore single quote, required because escape is augmented 92 (syntoken "'" :nospec t) 93 (synaugment :escape :variable) 94 ) 95 96 ;; escaped commands 97 (syntoken "`" :nospec t :contained t :begin :escape) 98 (syntable :escape *prop-escape* #'default-indent 99 ;; escaped characters 100 (syntoken "\\\\." :property *prop-backslash*) 101 (syntoken "`" :nospec t :switch -1) 102 ;; rule to start double quote inside escape 103 (syntoken "\"" :nospec t :contained t :begin :double) 104 ;; rule to start single quote 105 (syntoken "'" :nospec t :contained t :begin :single) 106 (synaugment :double :variable) 107 ) 108 109 (syntable :variable nil nil 110 (syntoken "\\$\\w+" :property *prop-variable*) 111 ) 112 (synaugment :variable) 113) 114