15dfecf96Smrg;; 25dfecf96Smrg;; Copyright (c) 2003 by The XFree86 Project, Inc. 35dfecf96Smrg;; 45dfecf96Smrg;; Permission is hereby granted, free of charge, to any person obtaining a 55dfecf96Smrg;; copy of this software and associated documentation files (the "Software"), 65dfecf96Smrg;; to deal in the Software without restriction, including without limitation 75dfecf96Smrg;; the rights to use, copy, modify, merge, publish, distribute, sublicense, 85dfecf96Smrg;; and/or sell copies of the Software, and to permit persons to whom the 95dfecf96Smrg;; Software is furnished to do so, subject to the following conditions: 105dfecf96Smrg;; 115dfecf96Smrg;; The above copyright notice and this permission notice shall be included in 125dfecf96Smrg;; all copies or substantial portions of the Software. 135dfecf96Smrg;; 145dfecf96Smrg;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 155dfecf96Smrg;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 165dfecf96Smrg;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 175dfecf96Smrg;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 185dfecf96Smrg;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 195dfecf96Smrg;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 205dfecf96Smrg;; SOFTWARE. 215dfecf96Smrg;; 225dfecf96Smrg;; Except as contained in this notice, the name of the XFree86 Project shall 235dfecf96Smrg;; not be used in advertising or otherwise to promote the sale, use or other 245dfecf96Smrg;; dealings in this Software without prior written authorization from the 255dfecf96Smrg;; XFree86 Project. 265dfecf96Smrg;; 275dfecf96Smrg;; Author: Paulo César Pereira de Andrade 285dfecf96Smrg;; 295dfecf96Smrg;; 305dfecf96Smrg;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/sh.lsp,v 1.1 2003/01/16 03:50:46 paulo Exp $ 315dfecf96Smrg;; 325dfecf96Smrg 335dfecf96Smrg(require "syntax") 345dfecf96Smrg(require "indent") 355dfecf96Smrg(in-package "XEDIT") 365dfecf96Smrg 375dfecf96Smrg(defsynprop *prop-escape* 385dfecf96Smrg "escape" 395dfecf96Smrg :font "*lucidatypewriter-medium-r*-12-*" 405dfecf96Smrg :foreground "Red3") 415dfecf96Smrg 425dfecf96Smrg(defsynprop *prop-variable* 435dfecf96Smrg "variable" 445dfecf96Smrg :font "*lucidatypewriter-medium-r*-12-*" 455dfecf96Smrg :foreground "Gold4") 465dfecf96Smrg 475dfecf96Smrg(defsynprop *prop-backslash* 485dfecf96Smrg "backslash" 495dfecf96Smrg :font "*courier-bold-r*-12-*" 505dfecf96Smrg :foreground "green4") 515dfecf96Smrg 525dfecf96Smrg;; XXX it would be interesting if "here-documents" could be parsed 535dfecf96Smrg;; just searching for "<<\s*EOF\\>" and then for "^EOF\\>" should 545dfecf96Smrg;; handle most cases, but would be a hack... 555dfecf96Smrg(defsyntax *sh-mode* :main nil #'default-indent nil 565dfecf96Smrg ;; keywords and common commands/builtins 575dfecf96Smrg (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)\\>" 585dfecf96Smrg :property *prop-keyword*) 595dfecf96Smrg 605dfecf96Smrg ; comments 615dfecf96Smrg (syntoken "#.*$" :property *prop-comment*) 625dfecf96Smrg 635dfecf96Smrg ;; punctuation 645dfecf96Smrg (syntoken "[][;:*?(){}<>&!|$#]+" :property *prop-punctuation*) 655dfecf96Smrg 665dfecf96Smrg ;; variable declaration 675dfecf96Smrg (syntoken "\\w+=" :property *prop-preprocessor*) 685dfecf96Smrg 695dfecf96Smrg ;; numbers 705dfecf96Smrg (syntoken "\\<\\d+\\>" :property *prop-number*) 715dfecf96Smrg 725dfecf96Smrg ;; escaped characters at toplevel 735dfecf96Smrg (syntoken "\\\\." :property *prop-backslash*) 745dfecf96Smrg 755dfecf96Smrg ;; single quote 765dfecf96Smrg (syntoken "'" :nospec t :contained t :begin :single) 775dfecf96Smrg (syntable :single *prop-constant* nil 785dfecf96Smrg ;; do nothing, escaped characters 795dfecf96Smrg (syntoken "\\\\.") 805dfecf96Smrg (syntoken "'" :nospec t :switch -1) 815dfecf96Smrg ) 825dfecf96Smrg 835dfecf96Smrg ;; double quote 845dfecf96Smrg (syntoken "\"" :nospec t :contained t :begin :double) 855dfecf96Smrg (syntable :double *prop-string* #'default-indent 865dfecf96Smrg ;; escaped characters 875dfecf96Smrg (syntoken "\\\\." :property *prop-backslash*) 885dfecf96Smrg (syntoken "\"" :nospec t :switch -1) 895dfecf96Smrg ;; rule to start escape 905dfecf96Smrg (syntoken "`" :nospec t :contained t :begin :escape) 915dfecf96Smrg ;; ignore single quote, required because escape is augmented 925dfecf96Smrg (syntoken "'" :nospec t) 935dfecf96Smrg (synaugment :escape :variable) 945dfecf96Smrg ) 955dfecf96Smrg 965dfecf96Smrg ;; escaped commands 975dfecf96Smrg (syntoken "`" :nospec t :contained t :begin :escape) 985dfecf96Smrg (syntable :escape *prop-escape* #'default-indent 995dfecf96Smrg ;; escaped characters 1005dfecf96Smrg (syntoken "\\\\." :property *prop-backslash*) 1015dfecf96Smrg (syntoken "`" :nospec t :switch -1) 1025dfecf96Smrg ;; rule to start double quote inside escape 1035dfecf96Smrg (syntoken "\"" :nospec t :contained t :begin :double) 1045dfecf96Smrg ;; rule to start single quote 1055dfecf96Smrg (syntoken "'" :nospec t :contained t :begin :single) 1065dfecf96Smrg (synaugment :double :variable) 1075dfecf96Smrg ) 1085dfecf96Smrg 1095dfecf96Smrg (syntable :variable nil nil 1105dfecf96Smrg (syntoken "\\$\\w+" :property *prop-variable*) 1115dfecf96Smrg ) 1125dfecf96Smrg (synaugment :variable) 1135dfecf96Smrg) 114