sync code with last improvements from OpenBSD
This commit is contained in:
commit
88965415ff
26235 changed files with 29195616 additions and 0 deletions
111
app/xedit/lisp/modules/progmodes/auto.lsp
Normal file
111
app/xedit/lisp/modules/progmodes/auto.lsp
Normal file
|
@ -0,0 +1,111 @@
|
|||
;; Copyright (c) 2007,2008 Paulo Cesar Pereira de Andrade
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice (including the next
|
||||
;; paragraph) shall be included in all copies or substantial portions of the
|
||||
;; Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
;; DEALINGS IN THE SOFTWARE.
|
||||
;;
|
||||
;; Author: Paulo Cesar Pereira de Andrade
|
||||
;;
|
||||
|
||||
;; Mode for editing autoconf/automake m4 files
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-macro*
|
||||
"macro"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "green4")
|
||||
|
||||
(defsynprop *prop-separator*
|
||||
"separator"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "Red3")
|
||||
|
||||
(defsynprop *prop-variable*
|
||||
"variable"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "Gold4")
|
||||
|
||||
(defsynprop *prop-escape*
|
||||
"escape"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "Red3")
|
||||
|
||||
(defsyntax *auto-mode* :main nil nil nil
|
||||
;; dont consider dnl a macro call at top level
|
||||
(syntoken "(#.*|\\<dnl($|\\>.*))" :property *prop-comment*)
|
||||
|
||||
;; shell keywords
|
||||
(syntoken
|
||||
(string-concat
|
||||
"\\<("
|
||||
"if|then|else|elif|else|fi|case|in|esac|do|done"
|
||||
")\\>") :property *prop-keyword*)
|
||||
|
||||
;; toplevel no arguments macro
|
||||
(syntoken "^[a-zA-Z0-9_]+$" :property *prop-macro*)
|
||||
|
||||
(syntable :string *prop-string* nil
|
||||
;; ignore escaped characters
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\"" :nospec t :switch -1)
|
||||
(synaugment :variables))
|
||||
(syntable :constant *prop-constant* nil
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "'" :nospec t :switch -1)
|
||||
(synaugment :variables))
|
||||
(syntable :escape *prop-escape* nil
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "`" :nospec t :switch -1)
|
||||
(synaugment :variables))
|
||||
|
||||
(syntable :quoted-string *prop-string* nil
|
||||
(syntoken "\\\"" :nospec t :switch -1))
|
||||
|
||||
(syntable :macro *prop-default* nil
|
||||
(syntoken "," :property *prop-separator*)
|
||||
(syntoken "[" :nospec t :property *prop-separator* :begin :quoted)
|
||||
(syntable :quoted *prop-default* nil
|
||||
;; allow nesting
|
||||
(syntoken "[" :nospec t :property *prop-separator* :begin :quoted)
|
||||
(syntoken "]" :nospec t :property *prop-separator* :switch -1)
|
||||
(synaugment :shared :comments :variables))
|
||||
(syntoken ")" :nospec t :property *prop-macro* :switch -1)
|
||||
(synaugment :shared :quotes :variables :comments))
|
||||
|
||||
(syntable :shared nil nil
|
||||
(syntoken "[a-zA-Z0-9_]+\\(" :property *prop-macro* :begin :macro)
|
||||
;; variable assignment
|
||||
(syntoken "[a-zA-Z0-9_-]+=" :property *prop-keyword*))
|
||||
|
||||
(syntable :quotes nil nil
|
||||
(syntoken "\"" :nospec t :begin :string :contained t)
|
||||
(syntoken "'" :nospec t :begin :constant :contained t)
|
||||
(syntoken "`" :nospec t :begin :escape :contained t)
|
||||
(syntoken "\\\"" :nospec t :begin :quoted-string :contained t))
|
||||
|
||||
(syntable :variables nil nil
|
||||
(syntoken "\\$[a-zA-Z0-9_-]+" :property *prop-variable*)
|
||||
(syntoken "\\$\\{[a-zA-Z0-9_-]+\\}" :property *prop-variable*)
|
||||
(syntoken "\\$\\([a-zA-Z0-9_-]+\\)" :property *prop-variable*))
|
||||
|
||||
(syntable :comments nil nil
|
||||
(syntoken "(#.*|\\<dnl($|\\>.*))" :property *prop-comment*))
|
||||
|
||||
(synaugment :shared :quotes :variables))
|
1140
app/xedit/lisp/modules/progmodes/c.lsp
Normal file
1140
app/xedit/lisp/modules/progmodes/c.lsp
Normal file
File diff suppressed because it is too large
Load diff
327
app/xedit/lisp/modules/progmodes/html.lsp
Normal file
327
app/xedit/lisp/modules/progmodes/html.lsp
Normal file
|
@ -0,0 +1,327 @@
|
|||
;;
|
||||
;; Copyright (c) 2002 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/html.lsp,v 1.2 2002/09/22 18:41:27 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
#|
|
||||
This is not a validation tool for html.
|
||||
|
||||
It is possible to, using macros generate all combinations of text attributes,
|
||||
to properly handle <b>...<i>...</i>...</b> etc, as well as generating macros
|
||||
to automatically closing tags, but for now this file was built to work as an
|
||||
experience with the syntax highlight code.
|
||||
|#
|
||||
|
||||
(defsynprop *prop-html-default*
|
||||
"default"
|
||||
:font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10")
|
||||
|
||||
(defsynprop *prop-html-bold*
|
||||
"bold"
|
||||
:font "-*-lucida-bold-r-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "Gray15")
|
||||
|
||||
(defsynprop *prop-html-italic*
|
||||
"italic"
|
||||
:font "-*-lucida-medium-i-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10")
|
||||
|
||||
(defsynprop *prop-html-pre*
|
||||
"pre"
|
||||
:font "-*-courier-medium-r-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10")
|
||||
|
||||
(defsynprop *prop-html-link*
|
||||
"link"
|
||||
:font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "Blue"
|
||||
:underline "t")
|
||||
|
||||
(defsynprop *prop-html-small*
|
||||
"small"
|
||||
:font "-*-lucida-medium-r-*-*-10-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10")
|
||||
|
||||
(defsynprop *prop-html-big*
|
||||
"big"
|
||||
:font "-*-lucida-medium-r-*-*-20-*-*-*-*-*-*-1"
|
||||
:foreground "Gray15")
|
||||
|
||||
(defsynprop *prop-html-name*
|
||||
"name"
|
||||
:font "-*-lucida-bold-r-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "Black"
|
||||
:background "rgb:e/f/e")
|
||||
|
||||
(defsynprop *prop-html-h1*
|
||||
"h1"
|
||||
:font "-*-lucida-bold-r-*-*-20-*-*-*-*-*-*-1"
|
||||
:foreground "Gray15")
|
||||
|
||||
(defsynprop *prop-html-h2*
|
||||
"h2"
|
||||
:font "-*-lucida-bold-r-*-*-17-*-*-*-*-*-*-1"
|
||||
:foreground "Gray15")
|
||||
|
||||
(defsynprop *prop-html-h4*
|
||||
"h4"
|
||||
:font "-*-lucida-bold-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Gray15")
|
||||
|
||||
(defsynprop *prop-html-h5*
|
||||
"h5"
|
||||
:font "-*-lucida-bold-r-*-*-10-*-*-*-*-*-*-1"
|
||||
:foreground "Gray15")
|
||||
|
||||
(defsynprop *prop-html-li*
|
||||
"li"
|
||||
:font "-*-lucida-bold-r-*-*-8-*-*-*-*-*-*-1"
|
||||
:foreground "rgb:0/5/0"
|
||||
:underline t)
|
||||
|
||||
(defsynprop *prop-html-hr*
|
||||
"hr"
|
||||
:font "-*-courier-bold-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "rgb:0/5/0"
|
||||
:overstrike t)
|
||||
|
||||
(defsynprop *prop-html-title*
|
||||
"title"
|
||||
:font "-*-lucida-medium-r-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "Red3"
|
||||
:underline "t")
|
||||
|
||||
(defsynprop *prop-html-tag*
|
||||
"tag"
|
||||
:font "-*-courier-medium-r-*-*-10-*-*-*-*-*-*-1"
|
||||
:foreground "green4")
|
||||
|
||||
(defsynprop *prop-html-string*
|
||||
"string"
|
||||
:font "-*-lucida-medium-r-*-*-10-*-*-*-*-*-*-1"
|
||||
:foreground "RoyalBlue2")
|
||||
|
||||
(defsynprop *prop-html-comment*
|
||||
"comment"
|
||||
:font "-*-courier-medium-o-*-*-10-*-*-*-*-*-*-1"
|
||||
:foreground "SlateBlue3")
|
||||
|
||||
(defsynprop *prop-html-entity*
|
||||
"entity"
|
||||
:font "-*-lucida-medium-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Red4")
|
||||
|
||||
(defsynprop *prop-html-unknown*
|
||||
"unknown"
|
||||
:font "-*-courier-bold-r-*-*-10-*-*-*-*-*-*-1"
|
||||
:foreground "yellow"
|
||||
:background "red")
|
||||
|
||||
(defmacro html-syntoken (name)
|
||||
`(syntoken (string-concat "<" ,name "\\>")
|
||||
:icase t :contained t
|
||||
:begin (intern (string-concat ,name "$") 'keyword)))
|
||||
(defmacro html-syntable (name property)
|
||||
`(let
|
||||
((label (intern (string-concat ,name "$") 'keyword))
|
||||
(nested-label (intern (string (gensym)) 'keyword)))
|
||||
(syntable label *prop-html-tag* nil
|
||||
(synaugment :generic-tag)
|
||||
(syntoken ">" :nospec t :property *prop-html-tag* :begin nested-label)
|
||||
(syntable nested-label ,property nil
|
||||
(syntoken (string-concat "</" ,name ">")
|
||||
:icase t :nospec t :property *prop-html-tag* :switch -2)
|
||||
(syntoken (string-concat "</" ,name "\\s*$")
|
||||
:icase t :contained t :begin :continued-end-tag)
|
||||
(synaugment :main)))))
|
||||
|
||||
|
||||
(defsyntax *html-mode* :main *prop-html-default* nil nil
|
||||
(syntoken "<!--" :nospec t :contained t :begin :comment)
|
||||
(syntable :comment *prop-html-comment* nil
|
||||
(syntoken "-->" :nospec t :switch -1))
|
||||
(syntoken "&([a-zA-Z0-9_.-]+|#\\x\\x?);?" :property *prop-html-entity*)
|
||||
(syntoken "<li>" :nospec t :icase t :property *prop-html-li*)
|
||||
(syntoken "<hr>" :nospec t :icase t :property *prop-html-hr*)
|
||||
|
||||
(syntoken "<img\\>" :icase t :contained t :begin :tag)
|
||||
(syntoken "<(p|br)>" :icase t :property *prop-html-tag*)
|
||||
|
||||
;; If in the toplevel, unbalanced!
|
||||
;; XXX When adding new nested tables, don't forget to update this pattern.
|
||||
(syntoken
|
||||
(string-concat
|
||||
"</("
|
||||
"b|strong|i|em|address|pre|code|tt|small|big|a|span|div|"
|
||||
"h1|h2|h3|h4|h5|title|font|ol|ul|dl|dt|dd|menu"
|
||||
")\\>")
|
||||
:icase t :property *prop-html-unknown* :begin :unbalanced)
|
||||
(syntable :unbalanced *prop-html-unknown* nil
|
||||
(syntoken ">" :nospec t :switch :main)
|
||||
(synaugment :generic-tag)
|
||||
)
|
||||
|
||||
#||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||
;; XXX ONLY add a rule for "html", "head" and "body" if you want to do a
|
||||
;; more complete check for common errors. If you add those rules, it will
|
||||
;; reparse the entire file at every character typed (unless there are
|
||||
;; errors in which case the parser resets the state).
|
||||
;; For visualization only that would be OK...
|
||||
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||#
|
||||
|
||||
(html-syntoken "b")
|
||||
(html-syntable "b" *prop-html-bold*)
|
||||
(html-syntoken "strong")
|
||||
(html-syntable "strong" *prop-html-bold*)
|
||||
|
||||
(html-syntoken "i")
|
||||
(html-syntable "i" *prop-html-italic*)
|
||||
(html-syntoken "em")
|
||||
(html-syntable "em" *prop-html-italic*)
|
||||
(html-syntoken "address")
|
||||
(html-syntable "address" *prop-html-italic*)
|
||||
|
||||
(html-syntoken "pre")
|
||||
(html-syntable "pre" *prop-html-pre*)
|
||||
(html-syntoken "code")
|
||||
(html-syntable "code" *prop-html-pre*)
|
||||
(html-syntoken "tt")
|
||||
(html-syntable "tt" *prop-html-pre*)
|
||||
|
||||
(html-syntoken "small")
|
||||
(html-syntable "small" *prop-html-small*)
|
||||
|
||||
(html-syntoken "big")
|
||||
(html-syntable "big" *prop-html-big*)
|
||||
|
||||
;; Cannot hack html-syntoken and html-syntable to handle this,
|
||||
;; as the option to <a may be in the next line.
|
||||
(syntoken "<a\\>" :icase t :contained t :begin :a)
|
||||
(syntable :a *prop-html-tag* nil
|
||||
;; Tag is open
|
||||
(syntoken "\\<href\\>" :icase t :begin :a-href)
|
||||
(syntoken "\\<name\\>" :icase t :begin :a-name)
|
||||
(syntoken "<" :nospec t :property *prop-html-unknown* :switch -2)
|
||||
(synaugment :generic-tag)
|
||||
(syntoken ">" :nospec t :begin :a-generic-text)
|
||||
(syntable :a-href *prop-html-tag* nil
|
||||
(syntoken ">" :nospec t :begin :a-href-text)
|
||||
(synaugment :generic-tag)
|
||||
(syntable :a-href-text *prop-html-link* nil
|
||||
(syntoken "</a>"
|
||||
:icase t :nospec t :property *prop-html-tag* :switch -3)
|
||||
(syntoken "</a\\s*$" :icase t :begin :continued-nested-end-tag)
|
||||
(synaugment :main)
|
||||
)
|
||||
)
|
||||
(syntable :a-name *prop-html-tag* nil
|
||||
(syntoken ">" :nospec t :begin :a-name-text)
|
||||
(synaugment :generic-tag)
|
||||
(syntable :a-name-text *prop-html-name* nil
|
||||
(syntoken "</a>"
|
||||
:icase t :nospec t :property *prop-html-tag* :switch -3)
|
||||
(syntoken "</a\\s*$" :icase t :begin :continued-nested-end-tag)
|
||||
(synaugment :main)
|
||||
)
|
||||
)
|
||||
(syntable :a-generic-text nil nil
|
||||
(syntoken "</a>"
|
||||
:icase t :nospec t :property *prop-html-tag* :switch -2)
|
||||
(syntoken "<a/\\s$" :icase t :begin :continued-end-tag)
|
||||
(synaugment :main)
|
||||
)
|
||||
)
|
||||
|
||||
;; Do nothing, just check start/end tags
|
||||
(html-syntoken "ol")
|
||||
(html-syntable "ol" nil)
|
||||
(html-syntoken "ul")
|
||||
(html-syntable "ul" nil)
|
||||
(html-syntoken "dl")
|
||||
(html-syntable "dl" nil)
|
||||
;; Maybe <dt> and <dd> should be in a special table, to not require
|
||||
;; and ending tag.
|
||||
;; XXX Maybe should also add a table for <p>.
|
||||
(html-syntoken "dt")
|
||||
(html-syntable "dt" nil)
|
||||
(html-syntoken "dd")
|
||||
(html-syntable "dd" nil)
|
||||
|
||||
(html-syntoken "span")
|
||||
(html-syntable "span" nil)
|
||||
(html-syntoken "div")
|
||||
(html-syntable "div" nil)
|
||||
(html-syntoken "menu")
|
||||
(html-syntable "menu" nil)
|
||||
|
||||
(html-syntoken "h1")
|
||||
(html-syntable "h1" *prop-html-h1*)
|
||||
(html-syntoken "h2")
|
||||
(html-syntable "h2" *prop-html-h2*)
|
||||
(html-syntoken "h3")
|
||||
(html-syntable "h3" *prop-html-bold*)
|
||||
(html-syntoken "h4")
|
||||
(html-syntable "h4" *prop-html-h4*)
|
||||
(html-syntoken "h5")
|
||||
(html-syntable "h5" *prop-html-h5*)
|
||||
(html-syntoken "title")
|
||||
(html-syntable "title" *prop-html-title*)
|
||||
|
||||
(html-syntoken "font")
|
||||
(html-syntable "font" *prop-control*)
|
||||
|
||||
(syntoken "<" :nospec t :contained t :begin :tag)
|
||||
(syntable :generic-tag *prop-html-tag* nil
|
||||
(syntoken "\"" :nospec t :contained t :begin :string)
|
||||
(syntoken "<" :nospec t :property *prop-html-unknown*)
|
||||
)
|
||||
(syntable :tag *prop-html-tag* nil
|
||||
(syntoken ">" :nospec t :switch -1)
|
||||
(synaugment :generic-tag)
|
||||
)
|
||||
;; Tag ended in a newline, common practice...
|
||||
(syntable :continued-end-tag *prop-html-tag* nil
|
||||
(syntoken ">" :nospec t :switch -3)
|
||||
(synaugment :generic-tag)
|
||||
)
|
||||
(syntable :continued-nested-end-tag *prop-html-tag* nil
|
||||
(syntoken ">" :nospec t :switch -4)
|
||||
(synaugment :generic-tag)
|
||||
)
|
||||
|
||||
(syntable :string *prop-html-string* nil
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\"" :nospec t :switch -1)
|
||||
)
|
||||
)
|
188
app/xedit/lisp/modules/progmodes/imake.lsp
Normal file
188
app/xedit/lisp/modules/progmodes/imake.lsp
Normal file
|
@ -0,0 +1,188 @@
|
|||
;;
|
||||
;; Copyright (c) 2002 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/imake.lsp,v 1.2 2002/10/06 17:11:48 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-shell*
|
||||
"shell"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "Red4"
|
||||
)
|
||||
|
||||
(defsynprop *prop-variable*
|
||||
"variable"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:foreground "Red3"
|
||||
)
|
||||
|
||||
;; The syntax-highlight definition does not try to flag errors, just show
|
||||
;; tabs in the start of lines for better visualization.
|
||||
(defsynprop *prop-tabulation*
|
||||
"tabulation"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:background "Gray90"
|
||||
)
|
||||
|
||||
(defsynprop *prop-xcomm*
|
||||
"xcomm"
|
||||
:font "*courier-medium-o*-12-*"
|
||||
:foreground "SkyBlue4"
|
||||
)
|
||||
|
||||
|
||||
(defsyntax *imake-mode* :main nil nil nil
|
||||
(syntoken "^\\s*XCOMM\\W?.*$"
|
||||
:property *prop-xcomm*)
|
||||
|
||||
(syntoken "^\\t+"
|
||||
:property *prop-tabulation*)
|
||||
|
||||
(syntoken "$("
|
||||
:nospec t
|
||||
:begin :shell
|
||||
:property *prop-shell*)
|
||||
|
||||
(syntoken "[][(){};$<=>&@/\\,.:~!|*?'`+-]"
|
||||
:property *prop-shell*)
|
||||
|
||||
;; Preprocessor start rule.
|
||||
(syntoken "^\\s*#\\s*\\w+"
|
||||
:begin :preprocessor
|
||||
:contained t)
|
||||
|
||||
;; Comment start rule.
|
||||
(syntoken "/*"
|
||||
:nospec t
|
||||
:begin :comment
|
||||
:contained t)
|
||||
|
||||
;; String start rule.
|
||||
(syntoken "\""
|
||||
:begin :string
|
||||
:nospec t
|
||||
:contained t)
|
||||
|
||||
;; Quoted string start rule.
|
||||
(syntoken "\\\""
|
||||
:begin :quoted-string
|
||||
:nospec t
|
||||
:contained t)
|
||||
|
||||
(syntable :shell *prop-variable* nil
|
||||
(syntoken ")"
|
||||
:nospec t
|
||||
:property *prop-shell*
|
||||
:switch -1)
|
||||
)
|
||||
|
||||
;; Rules for comments.
|
||||
(syntable :comment *prop-comment* nil
|
||||
|
||||
;; Match nested comments as an error.
|
||||
(syntoken "/*"
|
||||
:nospec t
|
||||
:property *prop-error*)
|
||||
|
||||
(syntoken "XXX|TODO|FIXME"
|
||||
:property *prop-annotation*)
|
||||
|
||||
;; Rule to finish a comment.
|
||||
(syntoken "*/"
|
||||
:nospec t
|
||||
:switch -1)
|
||||
)
|
||||
|
||||
;; Rules for preprocessor.
|
||||
(syntable :preprocessor *prop-preprocessor* nil
|
||||
|
||||
;; Preprocessor includes comments.
|
||||
(syntoken "/*"
|
||||
:nospec t
|
||||
:begin :comment
|
||||
:contained t)
|
||||
|
||||
;; Visualization help, show tabs in the start of lines.
|
||||
(syntoken "^\\t+"
|
||||
:property *prop-tabulation*)
|
||||
|
||||
;; Ignore lines finishing with a backslash.
|
||||
(syntoken "\\\\$")
|
||||
|
||||
;; Return to previous state if end of line found.
|
||||
(syntoken ".?$"
|
||||
:switch -1)
|
||||
)
|
||||
|
||||
;; Rules for strings.
|
||||
(syntable :string *prop-string* nil
|
||||
|
||||
;; Ignore escaped characters, this includes \".
|
||||
(syntoken "\\\\.")
|
||||
|
||||
;; Ignore continuation in the next line.
|
||||
(syntoken "\\\\$")
|
||||
|
||||
;; Rule to finish a string.
|
||||
(syntoken "\""
|
||||
:nospec t
|
||||
:switch -1)
|
||||
|
||||
;; Don't allow strings continuing in the next line.
|
||||
(syntoken ".?$"
|
||||
:begin :error)
|
||||
)
|
||||
|
||||
;; Rules for quoted strings.
|
||||
(syntable :quoted-string *prop-constant* nil
|
||||
|
||||
;; Rule to finish the quoted string.
|
||||
(syntoken "\\\""
|
||||
:nospec t
|
||||
:switch -1)
|
||||
|
||||
;; Ignore escaped characters
|
||||
(syntoken "\\\\.")
|
||||
|
||||
;; Ignore continuation in the next line.
|
||||
(syntoken "\\\\$")
|
||||
|
||||
;; Don't allow strings continuing in the next line.
|
||||
(syntoken ".?$"
|
||||
:begin :error)
|
||||
)
|
||||
|
||||
(syntable :error *prop-error* nil
|
||||
(syntoken "^.*$"
|
||||
:switch -2)
|
||||
)
|
||||
)
|
384
app/xedit/lisp/modules/progmodes/lisp.lsp
Normal file
384
app/xedit/lisp/modules/progmodes/lisp.lsp
Normal file
|
@ -0,0 +1,384 @@
|
|||
;;
|
||||
;; Copyright (c) 2002 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/lisp.lsp,v 1.9 2003/01/30 02:46:26 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(require "indent")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-special*
|
||||
"special"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "NavyBlue"
|
||||
)
|
||||
|
||||
(defsynprop *prop-quote*
|
||||
"quote"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "Red4"
|
||||
)
|
||||
|
||||
(defsynprop *prop-package*
|
||||
"package"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "Gold4"
|
||||
)
|
||||
|
||||
(defsynprop *prop-unreadable*
|
||||
"unreadable"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:foreground "Gray25"
|
||||
:underline t
|
||||
)
|
||||
|
||||
(defsynoptions *lisp-DEFAULT-style*
|
||||
;; Positive number. Basic indentation.
|
||||
(:indentation . 2)
|
||||
|
||||
;; Boolean. Move cursor to the indent column after pressing <Enter>?
|
||||
(:newline-indent . t)
|
||||
|
||||
;; Boolean. Use spaces instead of tabs to fill indentation?
|
||||
(:emulate-tabs . nil)
|
||||
|
||||
;; Boolean. Remove extra spaces from previous line.
|
||||
;; This should default to T when newline-indent is not NIL.
|
||||
(:trim-blank-lines . t)
|
||||
|
||||
;; Boolean. If this hash-table entry is set, no indentation is done.
|
||||
;; Useful to temporarily disable indentation.
|
||||
(:disable-indent . nil)
|
||||
)
|
||||
|
||||
(defvar *lisp-mode-options* *lisp-DEFAULT-style*)
|
||||
|
||||
(defindent *lisp-mode-indent* :main
|
||||
;; this must be the first token
|
||||
(indtoken "^\\s*" :indent
|
||||
:code (or *offset* (setq *offset* (+ *ind-offset* *ind-length*))))
|
||||
;; ignore single line comments
|
||||
(indtoken ";.*$" nil)
|
||||
;; multiline comments
|
||||
(indtoken "|#" :comment :nospec t :begin :comment)
|
||||
;; characters
|
||||
(indtoken "#\\\\(\\W|\\w+(-\\w+)?)" :character)
|
||||
;; numbers
|
||||
(indtoken
|
||||
(string-concat
|
||||
"(\\<|[+-])\\d+("
|
||||
;; integers
|
||||
"(\\>|\\.(\\s|$))|"
|
||||
;; ratios
|
||||
"/\\d+\\>|"
|
||||
;;floats
|
||||
"\\.?\\d*([SsFfDdLlEe][+-]?\\d+)?\\>"
|
||||
")")
|
||||
:number)
|
||||
;; symbols, with optional package
|
||||
(indtoken
|
||||
(string-concat
|
||||
;; optional package name and ending ':'
|
||||
"([A-Za-z_0-9%-]+:)?"
|
||||
;; internal symbol if after package name, or keyword
|
||||
":?"
|
||||
;; symbol name
|
||||
"[][{}A-Za-z_0-9!$%&/<=>^~*+-]+")
|
||||
:symbol)
|
||||
;; strings in the same line
|
||||
(indtoken "\"([^\\\"]|\\\\.)*\"" :string)
|
||||
;; multiline strings
|
||||
(indtoken "\"" :cstring :nospec t :begin :string)
|
||||
;; "quoted" symbols in the same line
|
||||
(indtoken "\\|([^\\|]|\\\\.)*\\|" :symbol)
|
||||
;; multiline
|
||||
(indtoken "|" :csymbol :nospec t :begin :symbol)
|
||||
(indtoken "#" :hash :nospec t)
|
||||
|
||||
(indinit (parens 0))
|
||||
(indtoken "(" :oparen :nospec t :code (incf parens))
|
||||
(indtoken ")" :cparen :nospec t :code (decf parens))
|
||||
|
||||
(indtable :comment
|
||||
;; multiline comments can nest
|
||||
(indtoken "|#" nil :nospec t :begin :comment)
|
||||
(indtoken "#|" nil :nospec t :switch -1))
|
||||
|
||||
(indtable :string
|
||||
;; Ignore escaped characters
|
||||
(indtoken "\\." nil)
|
||||
;; Return to the toplevel when the start of the string is found
|
||||
(indtoken "\"" :ostring :nospec t :switch -1))
|
||||
|
||||
(indtable :symbol
|
||||
;; Ignore escaped characters
|
||||
(indtoken "\\." nil)
|
||||
;; Return to the toplevel when the start of the symbol is found
|
||||
(indtoken "|" :osymbol :nospec t :switch -1))
|
||||
|
||||
;; ignore comments
|
||||
(indreduce nil
|
||||
t
|
||||
((:comment)))
|
||||
|
||||
;; reduce multiline strings
|
||||
(indreduce :string
|
||||
t
|
||||
((:ostring (not :ostring) :cstring)))
|
||||
|
||||
;; reduce multiline symbols
|
||||
(indreduce :symbol
|
||||
t
|
||||
((:osymbol (not :osymbol) :csymbol)))
|
||||
|
||||
;; reduce basic types, don't care if inside list or not
|
||||
(indreduce :element
|
||||
t
|
||||
((:number)
|
||||
(:string)
|
||||
(:character)
|
||||
(:element :element)
|
||||
(:indent :element)))
|
||||
|
||||
(indreduce :symbol
|
||||
t
|
||||
((:symbol :symbol)
|
||||
(:symbol :element)
|
||||
(:indent :symbol)))
|
||||
|
||||
;; the "real" indentation value, to make easier parsing code like:
|
||||
;; (foo (bar (baz (blah
|
||||
;; ^ ^
|
||||
;; | |
|
||||
;; indent |
|
||||
;; effective indentation to be used
|
||||
(indinit (indent 0))
|
||||
|
||||
;; indentation values of opening parenthesis.
|
||||
(indinit stack)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; if before current line and open parenthesis >= 0, use indentation
|
||||
;; of current line to calculate relative indentation.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(indreduce :oparen ;; simple list?
|
||||
(and (>= parens 0) (< *ind-offset* *ind-start*))
|
||||
((:indent :oparen))
|
||||
(setq
|
||||
*indent* (offset-indentation (+ *ind-offset* *ind-length*) :resolve t)
|
||||
indent *indent*)
|
||||
(indent-macro-reject-left))
|
||||
|
||||
;; reduce list if there isn't indentation change
|
||||
(indreduce :element
|
||||
t
|
||||
((:oparen (not :oparen) :cparen)))
|
||||
|
||||
(indresolve :oparen
|
||||
(setq
|
||||
*indent*
|
||||
(offset-indentation
|
||||
(+ *ind-offset* *ind-length* -1 *base-indent*) :align t))
|
||||
(push *indent* stack)
|
||||
(incf indent *base-indent*)
|
||||
(if (< *indent* indent) (setq *indent* indent)))
|
||||
|
||||
(indresolve :cparen
|
||||
(decf indent *base-indent*)
|
||||
(setq *indent* (pop stack))
|
||||
(if (null stack)
|
||||
(setq *indent* indent)
|
||||
(setq *indent* (car stack))))
|
||||
)
|
||||
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Find a "good" offset to start parsing backwards, so that it should
|
||||
;; always generate the same results.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defun lisp-offset-indent (&aux char (point (scan (point) :eol :left)))
|
||||
;; skip spaces
|
||||
(while (member (setq char (char-after point)) indent-spaces)
|
||||
(incf point))
|
||||
(if (member char '(#\))) (1+ point) point))
|
||||
|
||||
(defun lisp-should-indent (options &aux char point start)
|
||||
(when (hash-table-p options)
|
||||
;; check if previous line has extra spaces
|
||||
(and (gethash :trim-blank-lines options)
|
||||
(indent-clear-empty-line))
|
||||
|
||||
;; indentation disabled?
|
||||
(and (gethash :disable-indent options)
|
||||
(return-from lisp-should-indent))
|
||||
|
||||
(setq
|
||||
point (point)
|
||||
char (char-before (point))
|
||||
start (scan point :eol :left))
|
||||
|
||||
;; at the start of a line
|
||||
(and (= point start)
|
||||
(return-from lisp-should-indent (gethash :newline-indent options)))
|
||||
|
||||
;; if first character
|
||||
(and (= point (1+ start)) (return-from lisp-should-indent t))
|
||||
|
||||
;; if closing parenthesis and first nonblank char
|
||||
(when (and (characterp char) (char= char #\)))
|
||||
(decf point)
|
||||
(while
|
||||
(and (> point start) (member (char-before point) indent-spaces))
|
||||
(decf point))
|
||||
(return-from lisp-should-indent (<= point start)))
|
||||
)
|
||||
;; should not indent
|
||||
nil)
|
||||
|
||||
(defun lisp-indent (syntax syntable)
|
||||
(let*
|
||||
((options (syntax-options syntax))
|
||||
*base-indent*)
|
||||
|
||||
(or (lisp-should-indent options) (return-from lisp-indent))
|
||||
|
||||
(setq *base-indent* (gethash :indentation options 2))
|
||||
|
||||
(indent-macro
|
||||
*lisp-mode-indent*
|
||||
(lisp-offset-indent)
|
||||
(gethash :emulate-tabs options))))
|
||||
|
||||
(compile 'lisp-indent)
|
||||
|
||||
(defsyntax *lisp-mode* :main nil #'lisp-indent *lisp-mode-options*
|
||||
;; highlight car and parenthesis
|
||||
(syntoken "\\(+\\s*[][{}A-Za-z_0-9!$%&/<=>?^~*:+-]*\\)*"
|
||||
:property *prop-keyword*)
|
||||
(syntoken "\\)+" :property *prop-keyword*)
|
||||
|
||||
;; nil and t
|
||||
(syntoken "\\<(nil|t)\\>" :icase t :property *prop-special*)
|
||||
|
||||
(syntoken "|" :nospec t :begin :unreadable :contained t)
|
||||
|
||||
;; keywords
|
||||
(syntoken ":[][{}A-Za-z_0-9!$%&/<=>^~+-]+" :property *prop-constant*)
|
||||
|
||||
;; special symbol.
|
||||
(syntoken "\\*[][{}A-Za-z_0-9!$%&7=?^~+-]+\\*"
|
||||
:property *prop-special*)
|
||||
|
||||
;; special identifiers
|
||||
(syntoken "&(aux|key|optional|rest)\\>" :icase t :property *prop-constant*)
|
||||
|
||||
;; numbers
|
||||
(syntoken
|
||||
;; since lisp is very liberal in what can be a symbol, this pattern
|
||||
;; will not always work as expected, since \< and \> will not properly
|
||||
;; work for all characters that may be in a symbol name
|
||||
(string-concat
|
||||
"(\\<|[+-])\\d+("
|
||||
;; integers
|
||||
"(\\>|\\.(\\s|$))|"
|
||||
;; ratios
|
||||
"/\\d+\\>|"
|
||||
;;floats
|
||||
"\\.?\\d*([SsFfDdLlEe][+-]?\\d+)?\\>"
|
||||
")")
|
||||
:property *prop-number*)
|
||||
|
||||
;; characters
|
||||
(syntoken "#\\\\(\\W|\\w+(-\\w+)?)" :property *prop-constant*)
|
||||
|
||||
;; quotes
|
||||
(syntoken "[`'.]|,@?" :property *prop-quote*)
|
||||
|
||||
;; package names
|
||||
(syntoken "[A-Za-z_0-9%-]+::?" :property *prop-package*)
|
||||
|
||||
;; read time evaluation
|
||||
(syntoken "#\\d+#" :property *prop-preprocessor*)
|
||||
(syntoken "#([+'cCsS-]|\\d+[aA=])?" :begin :preprocessor :contained t)
|
||||
|
||||
(syntoken "\\c" :property *prop-control*)
|
||||
|
||||
;; symbols, do nothing, just resolve conflicting matches
|
||||
(syntoken "[][{}A-Za-z_0-9!$%&/<=>^~*+-]+")
|
||||
|
||||
(syntable :simple-comment *prop-comment* nil
|
||||
(syntoken "$" :switch -1)
|
||||
(syntoken "XXX|FIXME|TODO" :property *prop-annotation*))
|
||||
|
||||
(syntable :comment *prop-comment* nil
|
||||
;; comments can nest
|
||||
(syntoken "#|" :nospec t :begin :comment)
|
||||
;; return to previous state
|
||||
(syntoken "|#" :nospec t :switch -1)
|
||||
(syntoken "XXX|FIXME|TODO" :property *prop-annotation*))
|
||||
|
||||
(syntable :unreadable *prop-unreadable* nil
|
||||
;; ignore escaped characters
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "|" :nospec t :switch -1))
|
||||
|
||||
(syntable :string *prop-string* nil
|
||||
;; ignore escaped characters
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\"" :nospec t :switch -1))
|
||||
|
||||
(syntable :preprocessor *prop-preprocessor* nil
|
||||
;; a symbol
|
||||
(syntoken "[][{}A-Za-z_0-9!$%&/<=>^~:*+-]+" :switch -1)
|
||||
|
||||
;; conditional expression
|
||||
(syntoken "(" :nospec t :begin :preprocessor-expression :contained t)
|
||||
|
||||
(syntable :preprocessor-expression *prop-preprocessor* nil
|
||||
;; recursive
|
||||
(syntoken "(" :nospec t :begin :preprocessor-recursive :contained t)
|
||||
(syntoken ")" :nospec t :switch -2)
|
||||
|
||||
(syntable :preprocessor-recursive *prop-preprocessor* nil
|
||||
(syntoken "(" :nospec t
|
||||
:begin :preprocessor-recursive
|
||||
:contained t)
|
||||
(syntoken ")" :nospec t :switch -1)
|
||||
(synaugment :comments-and-strings))
|
||||
(synaugment :comments-and-strings))
|
||||
(synaugment :comments-and-strings))
|
||||
|
||||
(syntable :comments-and-strings nil nil
|
||||
(syntoken "\"" :nospec t :begin :string :contained t)
|
||||
(syntoken "#|" :nospec t :begin :comment :contained t)
|
||||
(syntoken ";" :begin :simple-comment :contained t))
|
||||
|
||||
(synaugment :comments-and-strings)
|
||||
)
|
135
app/xedit/lisp/modules/progmodes/make.lsp
Normal file
135
app/xedit/lisp/modules/progmodes/make.lsp
Normal file
|
@ -0,0 +1,135 @@
|
|||
;;
|
||||
;; Copyright (c) 2002 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/make.lsp,v 1.2 2002/10/06 17:11:48 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-shell*
|
||||
"shell"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "Red4"
|
||||
)
|
||||
|
||||
(defsynprop *prop-variable*
|
||||
"variable"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:foreground "Red3"
|
||||
)
|
||||
|
||||
;; The syntax-highlight definition does not try to flag errors, just show
|
||||
;; tabs in the start of lines for better visualization.
|
||||
(defsynprop *prop-tabulation*
|
||||
"tabulation"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:background "Gray90"
|
||||
)
|
||||
|
||||
|
||||
(defsyntax *make-mode* :main nil nil nil
|
||||
(syntoken "^\\t+" :property *prop-tabulation*)
|
||||
|
||||
(syntoken "^\\.\\w+" :property *prop-keyword*)
|
||||
|
||||
(syntoken "$("
|
||||
:nospec t
|
||||
:begin :shell
|
||||
:property *prop-shell*)
|
||||
|
||||
(syntoken "[][(){};$<=>&@/\\,.:~!|*?'`+-]"
|
||||
:property *prop-shell*)
|
||||
|
||||
;; Preprocessor start rule.
|
||||
(syntoken "#.*"
|
||||
:property *prop-comment*)
|
||||
|
||||
;; String start rule.
|
||||
(syntoken "\""
|
||||
:begin :string
|
||||
:nospec t
|
||||
:contained t)
|
||||
|
||||
;; Quoted string start rule.
|
||||
(syntoken "\\\""
|
||||
:begin :quoted-string
|
||||
:nospec t
|
||||
:contained t)
|
||||
|
||||
(syntable :shell *prop-variable* nil
|
||||
(syntoken ")"
|
||||
:nospec t
|
||||
:property *prop-shell*
|
||||
:switch -1)
|
||||
)
|
||||
|
||||
;; Rules for strings.
|
||||
(syntable :string *prop-string* nil
|
||||
|
||||
;; Ignore escaped characters, this includes \".
|
||||
(syntoken "\\\\.")
|
||||
|
||||
;; Ignore continuation in the next line.
|
||||
(syntoken "\\\\$")
|
||||
|
||||
;; Rule to finish a string.
|
||||
(syntoken "\""
|
||||
:nospec t
|
||||
:switch -1)
|
||||
|
||||
;; Don't allow strings continuing in the next line.
|
||||
(syntoken ".?$"
|
||||
:begin :error)
|
||||
)
|
||||
|
||||
;; Rules for quoted strings.
|
||||
(syntable :quoted-string *prop-constant* nil
|
||||
|
||||
;; Rule to finish the quoted string.
|
||||
(syntoken "\\\""
|
||||
:nospec t
|
||||
:switch -1)
|
||||
|
||||
;; Ignore escaped characters
|
||||
(syntoken "\\\\.")
|
||||
|
||||
;; Ignore continuation in the next line.
|
||||
(syntoken "\\\\$")
|
||||
|
||||
;; Don't allow strings continuing in the next line.
|
||||
(syntoken ".?$"
|
||||
:begin :error)
|
||||
)
|
||||
|
||||
(syntable :error *prop-error* nil
|
||||
(syntoken "^.*$"
|
||||
:switch -2)
|
||||
)
|
||||
)
|
160
app/xedit/lisp/modules/progmodes/man.lsp
Normal file
160
app/xedit/lisp/modules/progmodes/man.lsp
Normal file
|
@ -0,0 +1,160 @@
|
|||
;;
|
||||
;; Copyright (c) 2002 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/man.lsp,v 1.2 2002/10/06 17:11:48 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-man-b*
|
||||
"b"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "gray12"
|
||||
)
|
||||
|
||||
(defsynprop *prop-man-i*
|
||||
"i"
|
||||
:font "*courier-medium-o*-12-*"
|
||||
:foreground "black"
|
||||
)
|
||||
|
||||
(defsynprop *prop-man-bi*
|
||||
"bi"
|
||||
:font "*courier-bold-o*-12-*"
|
||||
:foreground "gray20"
|
||||
)
|
||||
|
||||
(defsynprop *prop-man-th*
|
||||
"th"
|
||||
:font "-*-courier-*-*-*-*-18-*-*-*-*-*-*-1"
|
||||
:foreground "Red3"
|
||||
)
|
||||
|
||||
(defsynprop *prop-man-sh*
|
||||
"sh"
|
||||
:font "-*-courier-*-*-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "OrangeRed3"
|
||||
)
|
||||
|
||||
(defsynprop *prop-man-ss*
|
||||
"ss"
|
||||
:font "-*-courier-*-*-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Gold4"
|
||||
)
|
||||
|
||||
(defsynprop *prop-man-escape*
|
||||
"escape"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "RoyalBlue4"
|
||||
)
|
||||
|
||||
(defsynprop *prop-man-string*
|
||||
"string"
|
||||
:font "*lucidatypewriter-bold-r*-12-*"
|
||||
:foreground "RoyalBlue3"
|
||||
; :underline t
|
||||
)
|
||||
|
||||
(defmacro man-syntoken (pattern)
|
||||
`(syntoken (string-concat "^\\.(" ,pattern ")(\\s+|$)")
|
||||
:icase t
|
||||
; :contained t
|
||||
:property *prop-preprocessor*
|
||||
:begin (intern (string ,pattern) 'keyword)))
|
||||
|
||||
(defmacro man-syntable (pattern property)
|
||||
`(syntable (intern (string ,pattern) 'keyword) ,property nil
|
||||
(syntoken "$" :switch -1)
|
||||
(synaugment :extras)))
|
||||
|
||||
|
||||
(defsyntax *man-mode* :main nil nil nil
|
||||
(syntoken "^\\.\\\\\".*"
|
||||
:property *prop-comment*)
|
||||
|
||||
(man-syntoken "b|br|nm")
|
||||
(man-syntable "b|br|nm" *prop-man-b*)
|
||||
|
||||
(man-syntoken "i|ir|ri|ip")
|
||||
(man-syntable "i|ir|ri|ip" *prop-man-i*)
|
||||
|
||||
(man-syntoken "th|dt")
|
||||
(man-syntable "th|dt" *prop-man-th*)
|
||||
|
||||
(man-syntoken "sh")
|
||||
(man-syntable "sh" *prop-man-sh*)
|
||||
|
||||
(man-syntoken "ss")
|
||||
(man-syntable "ss" *prop-man-ss*)
|
||||
|
||||
(man-syntoken "bi")
|
||||
(man-syntable "bi" *prop-man-bi*)
|
||||
|
||||
;; Anything not matched...
|
||||
(syntoken "^\\.[a-z][a-z](\\s+|$)"
|
||||
:icase t
|
||||
:property *prop-preprocessor*)
|
||||
|
||||
(syntable :extras nil nil
|
||||
(syntoken "\\<__\\l+__\\>"
|
||||
:property *prop-constant*)
|
||||
(syntoken "\\\\fB"
|
||||
:property *prop-preprocessor*
|
||||
:begin :b)
|
||||
(syntoken "\\\\fI"
|
||||
:property *prop-preprocessor*
|
||||
:begin :i)
|
||||
(syntoken "\\\\f\\u"
|
||||
:property *prop-preprocessor*)
|
||||
|
||||
(syntoken "\\\\\\*?."
|
||||
:property *prop-man-escape*)
|
||||
|
||||
(syntoken "\""
|
||||
:property *prop-man-string*)
|
||||
|
||||
(syntable :i *prop-man-i* nil
|
||||
(syntoken "$"
|
||||
:switch :main)
|
||||
(syntoken "\\\\f\\u"
|
||||
:property *prop-preprocessor*
|
||||
:switch -1)
|
||||
)
|
||||
(syntable :b *prop-man-b* nil
|
||||
(syntoken "$"
|
||||
:switch :main)
|
||||
(syntoken "\\\\f\\u"
|
||||
:property *prop-preprocessor*
|
||||
:switch -1)
|
||||
)
|
||||
)
|
||||
|
||||
(synaugment :extras)
|
||||
)
|
55
app/xedit/lisp/modules/progmodes/patch.lsp
Normal file
55
app/xedit/lisp/modules/progmodes/patch.lsp
Normal file
|
@ -0,0 +1,55 @@
|
|||
;;
|
||||
;; Copyright (c) 2003 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86$
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(require "indent")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsyntax *patch-mode* :main nil #'default-indent nil
|
||||
;; "normal" diff
|
||||
(syntoken "^(\\d+d\\d+|\\d+a\\d+,\\d+)$" :property *prop-keyword*)
|
||||
(syntoken "^<.*" :property *prop-constant*)
|
||||
(syntoken "^>.*" :property *prop-preprocessor*)
|
||||
|
||||
;; context diff
|
||||
(syntoken "^\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*\\*"
|
||||
:property *prop-string*)
|
||||
(syntoken "^\\*\\*\\* \\d+,\\d+ \\*\\*\\*\\*" :property *prop-comment*)
|
||||
(syntoken "^--- \\d+,\\d+ ----" :property *prop-comment*)
|
||||
|
||||
;; headers
|
||||
(syntoken "^(---|\\+\\+\\+|\\*\\*\\*).*" :property *prop-keyword*)
|
||||
|
||||
(syntoken "^@@ .*" :property *prop-comment*)
|
||||
(syntoken "^-.*" :property *prop-constant*)
|
||||
(syntoken "^\\+.*" :property *prop-preprocessor*)
|
||||
)
|
507
app/xedit/lisp/modules/progmodes/perl.lsp
Normal file
507
app/xedit/lisp/modules/progmodes/perl.lsp
Normal file
|
@ -0,0 +1,507 @@
|
|||
;; Copyright (c) 2007,2008 Paulo Cesar Pereira de Andrade
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice (including the next
|
||||
;; paragraph) shall be included in all copies or substantial portions of the
|
||||
;; Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
;; DEALINGS IN THE SOFTWARE.
|
||||
;;
|
||||
;; Author: Paulo Cesar Pereira de Andrade
|
||||
;;
|
||||
|
||||
;; Perl syntax and indentation mode
|
||||
;; Based on the C/C++ and Lisp modes. Attempting to make simple
|
||||
;; syntax/indentation rules, that should work correctly with most
|
||||
;; perl code.
|
||||
|
||||
;; *cont-indent* is somewhat buggy, that if pressing C-A,Tab, will
|
||||
;; not generate the same output as when normally typing the expression.
|
||||
;; This is because the parser doesn't search for a matching ';', '{',
|
||||
;; '[' or '(' to know where the expression starts. The C mode has the
|
||||
;; same problem. Example:
|
||||
;; a +
|
||||
;; b; <-- if pressing C-A,Tab will align "b;" with "a +"
|
||||
|
||||
;; Maybe most of the code here, and some code in the C mode could be
|
||||
;; merged to have a single "default mode" parser for languages that
|
||||
;; basically only depend on { and } for indentation.
|
||||
|
||||
(require "syntax")
|
||||
(require "indent")
|
||||
(in-package "XEDIT")
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defsynprop *prop-string-escape*
|
||||
"string-escape"
|
||||
:font "*lucidatypewriter-bold-r*-12-*"
|
||||
:foreground "RoyalBlue2"
|
||||
:underline t)
|
||||
|
||||
(defsynprop *prop-string-keyword-bold*
|
||||
"string-variable-bold"
|
||||
:font "*lucidatypewriter-bold-r*-12-*"
|
||||
:foreground "RoyalBlue4")
|
||||
|
||||
(defsynprop *prop-string-keyword*
|
||||
"string-variable"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "RoyalBlue4")
|
||||
|
||||
(defsynprop *prop-constant-escape*
|
||||
"constant-escape"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "VioletRed3"
|
||||
:underline t)
|
||||
|
||||
(defsynprop *prop-regex*
|
||||
"regex"
|
||||
:font "*courier-medium-o*-12-*"
|
||||
:foreground "black")
|
||||
|
||||
(defsynprop *prop-shell*
|
||||
"shell"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "red3")
|
||||
|
||||
(defsynprop *prop-shell-escape*
|
||||
"shell-escape"
|
||||
:font "*lucidatypewriter-bold-r*-12-*"
|
||||
:foreground "red3"
|
||||
:underline t)
|
||||
|
||||
(defsynprop *prop-documentation*
|
||||
"documentation"
|
||||
:font "fixed"
|
||||
:foreground "black"
|
||||
:background "rgb:e/e/e"
|
||||
)
|
||||
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defsynoptions *perl-DEFAULT-style*
|
||||
;; Positive number. Basic indentation
|
||||
(:indentation . 4)
|
||||
|
||||
;; Boolean. Add one indentation level to continuations?
|
||||
(:cont-indent . t)
|
||||
|
||||
;; Boolean. Move cursor to the indent column after pressing <Enter>?
|
||||
(:newline-indent . t)
|
||||
|
||||
;; Boolean. Set to T if tabs shouldn't be used to fill indentation.
|
||||
(:emulate-tabs . nil)
|
||||
|
||||
;; Boolean. Only calculate indentation after pressing <Enter>?
|
||||
;; This may be useful if the parser does not always
|
||||
;; do what the user expects...
|
||||
(:only-newline-indent . nil)
|
||||
|
||||
;; Boolean. Remove extra spaces from previous line.
|
||||
;; This should default to T when newline-indent is not NIL.
|
||||
(:trim-blank-lines . t)
|
||||
|
||||
;; Boolean. If this hash-table entry is set, no indentation is done.
|
||||
;; Useful to temporarily disable indentation.
|
||||
(:disable-indent . nil))
|
||||
|
||||
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defvar *perl-mode-options* *perl-DEFAULT-style*)
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
;; Parenthesis are usually not required, just distinguish as:
|
||||
;; expression: code without an ending ';'
|
||||
;; statement: code ending in a ';'
|
||||
;; block: code enclosed in '{' and '}'
|
||||
;; In Perl a simpler logic can be used, unlikely the C mode, as in
|
||||
;; perl braces are mandatory
|
||||
(defindent *perl-mode-indent* :main
|
||||
;; this must be the first token
|
||||
(indtoken "^\\s*" :indent
|
||||
:code (or *offset* (setq *offset* (+ *ind-offset* *ind-length*))))
|
||||
;; this may cause some other patterns to fail, due to matching single \'
|
||||
(indtoken "(&?(\\w+)|&(\\w+)?)'\\w+" :expression)
|
||||
;; special variables
|
||||
(indtoken "\\$(\\d|^\\u|[][0-9!#$*()_@<>?/|,\"'])" :expression)
|
||||
;; ignore comments
|
||||
(indtoken "#.*$" nil)
|
||||
;; treat regex as expressions to avoid confusing parser
|
||||
(indtoken "m?/([^/]|\\\\/)+/\\w*" :expression)
|
||||
(indtoken "m\\{[^}]+\\}\\w*" :expression)
|
||||
(indtoken "m<[^>]+>\\w*" :expression)
|
||||
(indtoken "(s|tr)/[^/]+/([^/]|\\\\/)*/\\w*" :expression)
|
||||
(indtoken "//" :expression :nospec t)
|
||||
;; fast resolve deferences to expressions
|
||||
(indtoken "[$@%&*]?\\{\\$?\\S+\\}" :expression)
|
||||
|
||||
(indtoken "($%@*)?\\w+" :expression)
|
||||
(indtoken ";" :semi :nospec t)
|
||||
(indinit (braces 0))
|
||||
(indtoken "{" :obrace :nospec t
|
||||
:code (decf braces))
|
||||
(indtoken "}" :cbrace :nospec t
|
||||
:code (incf braces))
|
||||
(indinit (parens&bracks 0))
|
||||
(indtoken ")" :cparen :nospec t :code (incf parens&bracks))
|
||||
(indtoken "(" :oparen :nospec t :code (decf parens&bracks))
|
||||
(indtoken "]" :cbrack :nospec t :code (incf parens&bracks))
|
||||
(indtoken "[" :obrack :nospec t :code (decf parens&bracks))
|
||||
;; if in the same line, reduce now, this must be done because the
|
||||
;; delimiters are identical
|
||||
(indtoken "'([^\\']|\\\\.)*'" :expression)
|
||||
(indtoken "\"([^\\\"]|\\\\.)*\"" :expression)
|
||||
(indtoken "\"" :cstring1 :nospec t :begin :string1)
|
||||
(indtoken "'" :cstring2 :nospec t :begin :string2)
|
||||
;; This must be the last rule
|
||||
(indtoken "\\s*$" :eol)
|
||||
|
||||
(indtable :string1
|
||||
;; Ignore escaped characters
|
||||
(indtoken "\\." nil)
|
||||
;; Return to the toplevel when the start of the string is found
|
||||
(indtoken "\"" :ostring1 :nospec t :switch -1))
|
||||
(indtable :string2
|
||||
(indtoken "\\." nil)
|
||||
(indtoken "'" :ostring2 :nospec t :switch -1))
|
||||
|
||||
;; This avoids some problems with *cont-indent* adding an indentation
|
||||
;; level to an expression after an empty line
|
||||
(indreduce nil
|
||||
t
|
||||
((:indent :eol)))
|
||||
|
||||
;; Reduce to a single expression token
|
||||
(indreduce :expression
|
||||
t
|
||||
((:indent :expression)
|
||||
(:expression :eol)
|
||||
(:expression :parens)
|
||||
(:expression :bracks)
|
||||
(:expression :expression)
|
||||
;; multiline strings
|
||||
(:ostring1 (not :ostring1) :cstring1)
|
||||
(:ostring2 (not :ostring2) :cstring2)
|
||||
;; parenthesis and brackets
|
||||
(:oparen (not :oparen) :cparen)
|
||||
(:obrack (not :obrack) :cbrack)))
|
||||
|
||||
;; Statements end in a semicollon
|
||||
(indreduce :statement
|
||||
t
|
||||
((:semi)
|
||||
(:indent :semi)
|
||||
(:expression :statement)
|
||||
(:statement :eol)
|
||||
;; Doesn't necessarily end in a semicollon
|
||||
(:expression :block)))
|
||||
|
||||
(indreduce :block
|
||||
t
|
||||
((:obrace (not :obrace) :cbrace)
|
||||
(:block :eol)))
|
||||
(indreduce :obrace
|
||||
(< *ind-offset* *ind-start*)
|
||||
((:indent :obrace))
|
||||
(setq *indent* (offset-indentation (+ *ind-offset* *ind-length*) :resolve t))
|
||||
(indent-macro-reject-left))
|
||||
|
||||
;; Try to do an smart indentation on open parenthesis and brackets
|
||||
(indreduce :parens
|
||||
t
|
||||
((:oparen (not :oparen) :cparen))
|
||||
(when (and
|
||||
(< *ind-offset* *ind-start*)
|
||||
(> (+ *ind-offset* *ind-length*) *ind-start*))
|
||||
(setq *indent* (1+ (offset-indentation *ind-offset* :align t)))
|
||||
(indent-macro-reject-left)))
|
||||
(indreduce :bracks
|
||||
t
|
||||
((:obrack (not :obrack) :cbrack))
|
||||
(when (and
|
||||
(< *ind-offset* *ind-start*)
|
||||
(> (+ *ind-offset* *ind-length*) *ind-start*))
|
||||
(setq *indent* (1+ (offset-indentation *ind-offset* :align t)))
|
||||
(indent-macro-reject-left)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Assuming previous lines have correct indentation, try to
|
||||
;; fast resolve brace indentation
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Line ended with an open brace
|
||||
(indreduce :obrace
|
||||
(< *ind-offset* *ind-start*)
|
||||
((:expression :obrace))
|
||||
(setq *indent* (offset-indentation *ind-offset* :resolve t))
|
||||
(indent-macro-reject-left))
|
||||
;; Line starts with an open brace
|
||||
(indreduce nil
|
||||
(< *ind-offset* *ind-start* (+ *ind-offset* *ind-length*))
|
||||
;; Just set initial indentation
|
||||
((:indent :obrace))
|
||||
(setq
|
||||
*indent* (- (offset-indentation *ind-offset* :resolve t) *base-indent*))
|
||||
(indent-macro-reject-left))
|
||||
|
||||
(indresolve :statement
|
||||
(when (< *ind-offset* *ind-start*)
|
||||
(while (> braces 0)
|
||||
(setq
|
||||
*indent* (- *indent* *base-indent*)
|
||||
braces (1- braces)))))
|
||||
|
||||
(indresolve :obrace
|
||||
(and (< *ind-offset* *ind-start*)
|
||||
(incf *indent* *base-indent*)))
|
||||
(indresolve :cbrace
|
||||
(decf *indent* *base-indent*))
|
||||
(indresolve :expression
|
||||
(and
|
||||
*cont-indent*
|
||||
(> *indent* 0)
|
||||
(zerop parens&bracks)
|
||||
(< *ind-offset* *ind-start*)
|
||||
(> (+ *ind-offset* *ind-length*) *ind-start*)
|
||||
(incf *indent* *base-indent*)))
|
||||
|
||||
(indresolve (:oparen :obrack)
|
||||
(and (< *ind-offset* *ind-start*)
|
||||
(setq *indent* (1+ (offset-indentation *ind-offset* :align t)))))
|
||||
)
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defun perl-offset-indent (&aux char (point (point)))
|
||||
;; Skip spaces forward
|
||||
(while (member (setq char (char-after point)) indent-spaces)
|
||||
(incf point))
|
||||
(if (member char '(#\})) (1+ point) point))
|
||||
|
||||
(compile 'perl-offset-indent)
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defun perl-should-indent (options &aux char point start offset)
|
||||
(when (hash-table-p options)
|
||||
;; check if previous line has extra spaces
|
||||
(and (gethash :trim-blank-lines options)
|
||||
(indent-clear-empty-line))
|
||||
|
||||
;; indentation disabled?
|
||||
(and (gethash :disable-indent options)
|
||||
(return-from perl-should-indent))
|
||||
|
||||
(setq
|
||||
point (point)
|
||||
char (char-before point)
|
||||
start (scan point :eol :left))
|
||||
|
||||
;; if at bol and should indent only when starting a line
|
||||
(and (gethash :only-newline-indent options)
|
||||
(return-from perl-should-indent (= point start)))
|
||||
|
||||
;; at the start of a line
|
||||
(and (= point start)
|
||||
(return-from perl-should-indent (gethash :newline-indent options)))
|
||||
|
||||
;; if first character
|
||||
(and (= point (1+ start))
|
||||
(return-from perl-should-indent t))
|
||||
|
||||
;; check if is the first non-blank character in a new line
|
||||
(when (and
|
||||
(gethash :cont-indent options)
|
||||
(= point (scan point :eol :right))
|
||||
(alphanumericp char))
|
||||
(setq offset (1- point))
|
||||
(while (and
|
||||
(> offset start)
|
||||
(member (char-before offset) indent-spaces))
|
||||
(decf offset))
|
||||
;; line has only one character with possible spaces before it
|
||||
(and (<= offset start)
|
||||
(return-from perl-should-indent t)))
|
||||
|
||||
;; if one of these was typed, should check indentation
|
||||
(if (member char '(#\})) (return-from perl-should-indent t))
|
||||
)
|
||||
;; Should not indent
|
||||
nil)
|
||||
|
||||
(compile 'perl-should-indent)
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defun perl-indent (syntax syntable)
|
||||
(let*
|
||||
((options (syntax-options syntax))
|
||||
*base-indent*
|
||||
*cont-indent*)
|
||||
|
||||
(or (perl-should-indent options) (return-from perl-indent))
|
||||
(setq
|
||||
*base-indent* (gethash :indentation options 4)
|
||||
*cont-indent* (gethash :cont-indent options t))
|
||||
|
||||
(indent-macro
|
||||
*perl-mode-indent*
|
||||
(perl-offset-indent)
|
||||
(gethash :emulate-tabs options))))
|
||||
|
||||
(compile 'perl-indent)
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
;; some example macros to easily add new patterns for strings and possibly
|
||||
;; regex or other patterns
|
||||
(defmacro perl-q-string-token (token)
|
||||
`(syntoken (string-concat "\\<q(q|w)?\\s*\\" ,token)
|
||||
:icase t :contained t :begin
|
||||
(intern (string-concat "string" ,token) 'keyword)))
|
||||
(defmacro perl-q-string-table (start end)
|
||||
`(syntable (intern (string-concat "string" ,start) 'keyword)
|
||||
*prop-string* #'default-indent
|
||||
(syntoken ,end :nospec t :switch -1)
|
||||
(synaugment :inside-string)))
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defsyntax *perl-mode* :main nil #'perl-indent *perl-mode-options*
|
||||
;; keywords
|
||||
(syntoken
|
||||
(string-concat
|
||||
"\\<("
|
||||
"and|for|foreach|gt|if|else|elsif|eq|goto|le|lt|last|ne|"
|
||||
"neg|next|not|or|return|shift|sub|unless|unshift|until|while"
|
||||
")\\>")
|
||||
:property *prop-keyword*)
|
||||
|
||||
;; pseudo keywords
|
||||
(syntoken
|
||||
(string-concat
|
||||
"\\<("
|
||||
"BEGIN|END|bless|blessed|defined|delete|eval|local|my|our|"
|
||||
"package|require|undef|use"
|
||||
")\\>")
|
||||
:property *prop-preprocessor*)
|
||||
;; this may cause some other patterns to fail, due to matching single \'
|
||||
(syntoken "(&?(\\w+)|&(\\w+)?)'\\w+" :property *prop-preprocessor*)
|
||||
|
||||
;; numbers
|
||||
(syntoken
|
||||
(string-concat
|
||||
"\\<("
|
||||
;; Integers
|
||||
"(\\d+|0x\\x+)|"
|
||||
;; Floats
|
||||
"\\d+\\.?\\d*(e[+-]?\\d+)?"
|
||||
")\\>")
|
||||
:icase t
|
||||
:property *prop-number*)
|
||||
|
||||
;; special variables
|
||||
(syntoken "\\$(\\d|^\\u|[][0-9!#$*()_@<>?/|,\"'])" :property *prop-keyword*)
|
||||
|
||||
;; also match variables
|
||||
(syntable :inside-string nil nil
|
||||
;; escaped characters
|
||||
|
||||
;; XXX This pattern was matching the empty string and entering an
|
||||
;; infinite loop in code like:
|
||||
#|
|
||||
---%<---
|
||||
" <-- *** if an backslash is added it fails. Inverting
|
||||
a"; *** the pattern fixed the problem, but was the wrong
|
||||
---%<--- *** solution. Note that C-G stops the interpreter, and
|
||||
*** special care must be taken with patterns matching
|
||||
*** empty strings.
|
||||
|#
|
||||
|
||||
(syntoken "\\\\\\d{3}|\\\\." :property *prop-string-escape*)
|
||||
(syntoken "(\\{\\$|\\$\\{)" :property *prop-string-keyword-bold* :begin :string-varbrace)
|
||||
(syntoken "[$@]" :property *prop-string-keyword-bold* :begin :string-variable)
|
||||
(syntoken "\\$(\\d|^\\u|[][0-9!#$*()_@<>?/|,\"'])" :property *prop-string-keyword-bold*))
|
||||
|
||||
;; variables insided strings
|
||||
(syntable :string-variable *prop-string-keyword* nil
|
||||
(syntoken "\\w+" :switch -1))
|
||||
(syntable :string-varbrace *prop-string-keyword* nil
|
||||
(syntoken "}"
|
||||
:nospec t
|
||||
:property *prop-string-keyword-bold*
|
||||
:switch -1)
|
||||
(synaugment :inside-string))
|
||||
|
||||
;; comments
|
||||
(syntoken "#.*$" :property *prop-comment*)
|
||||
|
||||
;; regex
|
||||
(syntoken "(\\<m)?/([^/]|\\\\/)+/\\w*" :property *prop-regex*)
|
||||
(syntoken "\\<m\\{[^}]+\\}\\w*" :property *prop-regex*)
|
||||
(syntoken "\\<m<[^>]+>\\w*" :property *prop-regex*)
|
||||
(syntoken "\\<(s|tr)/[^/]+/([^/]|\\\\/)*/\\w*":property *prop-regex*)
|
||||
;; just to avoid confusing the parser on something like split //, ...
|
||||
(syntoken "//" :nospec t :property *prop-regex*)
|
||||
|
||||
;; strings
|
||||
(syntoken "\"" :nospec t :contained t :begin :string)
|
||||
(syntable :string *prop-string* #'default-indent
|
||||
(syntoken "\"" :nospec t :switch -1)
|
||||
(synaugment :inside-string))
|
||||
|
||||
;; more strings
|
||||
(perl-q-string-token "{")
|
||||
(perl-q-string-table "{" "}")
|
||||
(perl-q-string-token "[")
|
||||
(perl-q-string-table "[" "]")
|
||||
(perl-q-string-token "(")
|
||||
(perl-q-string-table "(" ")")
|
||||
(perl-q-string-token "/")
|
||||
(perl-q-string-table "/" "/")
|
||||
|
||||
;; yet more strings
|
||||
(syntoken "'" :nospec t :contained t :begin :constant)
|
||||
(syntable :constant *prop-constant* #'default-indent
|
||||
(syntoken "'" :nospec t :switch -1)
|
||||
(syntoken "\\\\." :property *prop-string-escape*))
|
||||
|
||||
;; shell commands
|
||||
(syntoken "`" :nospec t :contained t :begin :shell)
|
||||
(syntable :shell *prop-shell* #'default-indent
|
||||
(syntoken "`" :nospec t :switch -1)
|
||||
(synaugment :inside-string))
|
||||
|
||||
;; punctuation
|
||||
(syntoken "[][$@%(){}/*+:;=<>,&!|^~\\.?-]" :property *prop-punctuation*)
|
||||
(syntoken "\\<x\\>" :property *prop-punctuation*)
|
||||
|
||||
;; primitive faked heredoc support, doesn't match the proper string, just
|
||||
;; expects an uppercase identifier in a single line
|
||||
(syntoken "<<\"[A-Z][A-Z0-9_]+\"" :property *prop-string* :begin :heredoc)
|
||||
(syntoken "<<'[A-Z][A-Z0-9_]+'" :property *prop-constant* :begin :heredoc)
|
||||
(syntoken "<<[A-Z][A-Z0-9_]+" :property *prop-preprocessor* :begin :heredoc)
|
||||
(syntable :heredoc *prop-documentation* #'default-indent
|
||||
(syntoken "^[A-Z][A-Z0-9_]+$" :switch -1))
|
||||
|
||||
(syntoken "^=(pod|item|over|head\\d)\\>.*$" :property *prop-documentation* :begin :info)
|
||||
(syntable :info *prop-documentation* nil
|
||||
(syntoken "^=cut\\>.*$" :switch -1)
|
||||
(syntoken "^.*$"))
|
||||
|
||||
(syntoken "^(__END__|__DATA__)$" :property *prop-documentation*
|
||||
:begin :documentation)
|
||||
|
||||
(syntoken "__\\u+__" :property *prop-preprocessor*)
|
||||
|
||||
(syntable :documentation *prop-documentation* nil
|
||||
(syntoken "^.*$"))
|
||||
|
||||
)
|
306
app/xedit/lisp/modules/progmodes/python.lsp
Normal file
306
app/xedit/lisp/modules/progmodes/python.lsp
Normal file
|
@ -0,0 +1,306 @@
|
|||
;; Copyright (c) 2008 Paulo Cesar Pereira de Andrade
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice (including the next
|
||||
;; paragraph) shall be included in all copies or substantial portions of the
|
||||
;; Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
;; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
;; FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
;; DEALINGS IN THE SOFTWARE.
|
||||
;;
|
||||
;; Author: Paulo Cesar Pereira de Andrade
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(require "indent")
|
||||
(in-package "XEDIT")
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defsynprop *prop-indent*
|
||||
"indent"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:background "Gray92")
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defsynoptions *python-DEFAULT-options*
|
||||
;; Positive number. Basic indentation
|
||||
(:indentation . 4)
|
||||
|
||||
;; Boolean. Move cursor to the indent column after pressing <Enter>?
|
||||
(:newline-indent . t)
|
||||
|
||||
;; Boolean. Set to T if tabs shouldn't be used to fill indentation.
|
||||
(:emulate-tabs . t)
|
||||
|
||||
;; Boolean. Only calculate indentation after pressing <Enter>?
|
||||
;; This may be useful if the parser does not always
|
||||
;; do what the user expects...
|
||||
(:only-newline-indent . nil)
|
||||
|
||||
;; Boolean. Remove extra spaces from previous line.
|
||||
;; This should default to T when newline-indent is not NIL.
|
||||
(:trim-blank-lines . nil)
|
||||
|
||||
;; Boolean. If this hash-table entry is set, no indentation is done.
|
||||
;; Useful to temporarily disable indentation.
|
||||
(:disable-indent . nil))
|
||||
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
;; Not doing "special" indentation of multiline ( because it is attempting
|
||||
;; to do a "smart" indentation and usually don't read more then one line
|
||||
;; back to resolve indentation.
|
||||
;; Code for multiline { and [, usually declaring vector/hash like variables
|
||||
;; should be working properly.
|
||||
;; Note that the indent lisp hook is only run on character additions, so
|
||||
;; it doesn't do a "smart" tabbing when pressing backspace, but it will
|
||||
;; properly align to the "closest tab stop" when typping a character.
|
||||
(defindent *python-mode-indent* :main
|
||||
;; this must be the first token
|
||||
(indtoken "^\\s*" :indent
|
||||
:code (or *offset* (setq *offset* (+ *ind-offset* *ind-length*))))
|
||||
|
||||
;; ignore comments
|
||||
(indtoken "#.*$" nil)
|
||||
|
||||
(indtoken ":" :collon :nospec t)
|
||||
|
||||
;; don't directly match {}, [], () strings, and :
|
||||
(indtoken "[a-zA-Z0-9+*/%^&<>=.,|!~-]+" :expression)
|
||||
|
||||
;; if in the same line, reduce now, as delimiters are identical
|
||||
(indtoken "'([^\\']|\\\\.)*'" :expression)
|
||||
(indtoken "\"([^\\\"]|\\\\.)*\"" :expression)
|
||||
;; otherwise, use a table
|
||||
(indtoken "\"" :cstring :nospec t :begin :string)
|
||||
(indtoken "'" :cconstant :nospec t :begin :constant)
|
||||
(indtoken "\"\"\"" :cstring3 :nospec t :begin :string3)
|
||||
(indtoken "'''" :cconstant :nospec t :begin :constant3)
|
||||
|
||||
(indinit (braces 0))
|
||||
(indtoken "}" :cbrace :nospec t :code (incf braces))
|
||||
(indtoken "{" :obrace :nospec t :code (decf braces))
|
||||
(indtoken ")" :cparen :nospec t :code (incf braces))
|
||||
(indtoken "(" :oparen :nospec t :code (decf braces))
|
||||
(indtoken "]" :cbrack :nospec t :code (incf braces))
|
||||
(indtoken "[" :obrack :nospec t :code (decf braces))
|
||||
|
||||
;; This must be the last token
|
||||
(indtoken "$" :eol)
|
||||
|
||||
(indtable :string
|
||||
;; Ignore escaped characters
|
||||
(indtoken "\\." nil)
|
||||
;; Return to the toplevel when the start of the string is found
|
||||
(indtoken "\"" :ostring :nospec t :switch -1))
|
||||
(indtable :constant
|
||||
(indtoken "\\." nil)
|
||||
(indtoken "'" :oconstant :nospec t :switch -1))
|
||||
|
||||
(indtable :string3
|
||||
(indtoken "\"\"\"" :ostring3 :nospec t :switch -1))
|
||||
(indtable :constant3
|
||||
(indtoken "'''" :oconstant3 :nospec t :switch -1))
|
||||
|
||||
;; Reduce what isn't reduced in regex pattern match
|
||||
(indreduce :expression
|
||||
t
|
||||
((:expression :expression)
|
||||
;; multiline strings
|
||||
(:ostring (not :ostring) :cstring)
|
||||
(:oconstant (not :oconstant) :cconstant)
|
||||
(:ostring3 (not :ostring3) :cstring3)
|
||||
(:oconstant3 (not :oconstant3) :cconstant3)
|
||||
;; braces, parenthesis and brackets
|
||||
(:obrace (not :obrace) :cbrace)
|
||||
(:oparen (not :oparen) :cparen)
|
||||
(:obrack (not :obrack) :cbrack)))
|
||||
|
||||
;; This should be the most common exit point;
|
||||
;; just copy previous line indentation.
|
||||
(indreduce :align
|
||||
(< *ind-offset* *ind-start*)
|
||||
((:indent :eol)
|
||||
(:indent :expression :eol))
|
||||
(setq *indent* (offset-indentation *offset* :resolve t))
|
||||
|
||||
;; If cursor is not in an indentation tab, assume user is trying to align
|
||||
;; to another block, and just use the resolve code to round it down
|
||||
(unless (/= (mod *indent* *base-indent*) 0)
|
||||
;; else use "previous-line" indentation.
|
||||
(setq *indent* (offset-indentation *ind-offset* :resolve t)))
|
||||
(indent-macro-reject-left))
|
||||
|
||||
;; This should be second most common exit point;
|
||||
;; add one indentation level.
|
||||
(indreduce :align
|
||||
(< *ind-offset* *ind-start*)
|
||||
((:indent :expression :collon :eol))
|
||||
(setq *indent* (+ *base-indent* (offset-indentation *ind-offset* :resolve t)))
|
||||
(indent-macro-reject-left))
|
||||
|
||||
(indresolve :align
|
||||
(setq *indent* (- *indent* (mod *indent* *base-indent*))))
|
||||
|
||||
;; Calculate special indentation for [ and {
|
||||
(indresolve (:obrack :obrace)
|
||||
(and
|
||||
(< *ind-offset* *ind-start*)
|
||||
(setq *indent* (+ *base-indent*
|
||||
(offset-indentation *ind-offset* :resolve t)))))
|
||||
(indresolve (:cbrack :cbrace)
|
||||
(setq *indent* (- (offset-indentation *ind-offset* :resolve t)
|
||||
(if (>= *ind-offset* *ind-start*)
|
||||
*base-indent* 0))))
|
||||
)
|
||||
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defun python-offset-indent (&aux char (point (point)))
|
||||
;; Skip spaces forward
|
||||
(while (member (setq char (char-after point)) indent-spaces)
|
||||
(incf point))
|
||||
point)
|
||||
|
||||
(compile 'python-offset-indent)
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defun python-should-indent (options &aux point start end offset)
|
||||
(when (hash-table-p options)
|
||||
;; check if previous line has extra spaces
|
||||
(and (gethash :trim-blank-lines options)
|
||||
(indent-clear-empty-line))
|
||||
|
||||
;; indentation disabled?
|
||||
(and (gethash :disable-indent options)
|
||||
(return-from python-should-indent))
|
||||
|
||||
(setq
|
||||
point (point)
|
||||
start (scan point :eol :left)
|
||||
end (scan point :eol :right))
|
||||
|
||||
;; if at bol and should indent only when starting a line
|
||||
(and (gethash :only-newline-indent options)
|
||||
(return-from python-should-indent (= point start)))
|
||||
|
||||
;; at the start of a line
|
||||
(and (= point start)
|
||||
(return-from python-should-indent (gethash :newline-indent options)))
|
||||
|
||||
;; if first character
|
||||
(and (= point (1+ start))
|
||||
(return-from python-should-indent t))
|
||||
|
||||
(setq offset start)
|
||||
(while (and
|
||||
(< offset end)
|
||||
(member (char-after offset) indent-spaces))
|
||||
(incf offset))
|
||||
|
||||
;; cursor is at first character in line, with possible spaces before it
|
||||
(return-from python-should-indent (or (= offset end) (= offset (1- point))))
|
||||
)
|
||||
;; Should not indent
|
||||
nil)
|
||||
|
||||
(compile 'python-should-indent)
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defun python-indent (syntax syntable)
|
||||
(let*
|
||||
((options (syntax-options syntax))
|
||||
*base-indent*)
|
||||
|
||||
(or (python-should-indent options) (return-from python-indent))
|
||||
(setq
|
||||
*base-indent* (gethash :indentation options 4))
|
||||
|
||||
(indent-macro
|
||||
*python-mode-indent*
|
||||
(python-offset-indent)
|
||||
(gethash :emulate-tabs options))))
|
||||
|
||||
(compile 'python-indent)
|
||||
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defvar *python-mode-options* *python-DEFAULT-options*)
|
||||
|
||||
|
||||
;=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
(defsyntax *python-mode* :main nil #'python-indent *python-mode-options*
|
||||
;; keywords
|
||||
(syntoken
|
||||
(string-concat
|
||||
"\\<("
|
||||
"and|break|class|continue|def|del|enumerate|except|False|for|"
|
||||
"elif|else|if|in|is|len|None|not|or|pass|print|raise|range|"
|
||||
"return|self|True|try|type|while|yield"
|
||||
")\\>")
|
||||
:property *prop-keyword*)
|
||||
|
||||
(syntoken "^\\s+" :property *prop-indent*)
|
||||
|
||||
;; preprocessor like
|
||||
(syntoken
|
||||
(string-concat
|
||||
"\\<("
|
||||
"from|import"
|
||||
")\\>")
|
||||
:property *prop-preprocessor*)
|
||||
|
||||
;; namespaces/accessors
|
||||
(syntoken "(\\w+\\.)+" :property *prop-preprocessor*)
|
||||
|
||||
;; more preprocessor like
|
||||
(syntoken "\\<__[a-zA-Z0-9]+__\\>" :property *prop-keyword*)
|
||||
|
||||
;; numbers
|
||||
(syntoken
|
||||
(string-concat
|
||||
"\\<("
|
||||
;; Integers
|
||||
"(\\d+|0x\\x+)L?|"
|
||||
;; Floats
|
||||
"\\d+\\.?\\d*(e[+-]?\\d+)?"
|
||||
")\\>")
|
||||
:icase t
|
||||
:property *prop-number*)
|
||||
|
||||
;; comments
|
||||
(syntoken "#.*" :property *prop-comment*)
|
||||
|
||||
;; punctuation
|
||||
(syntoken "[][(){}+*/%^&<>=.,|!~:-]+" :property *prop-punctuation*)
|
||||
|
||||
;; constant or constant like
|
||||
(syntoken "'" :nospec t :property *prop-constant* :begin :constant)
|
||||
(syntoken "'''" :nospec t :property *prop-constant* :begin :constant3)
|
||||
|
||||
;; strings
|
||||
(syntoken "\"" :nospec t :property *prop-string* :begin :string)
|
||||
(syntoken "\"\"\"" :nospec t :property *prop-string* :begin :string3)
|
||||
|
||||
(syntable :constant *prop-constant* nil
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "'" :nospec t :switch -1))
|
||||
(syntable :constant3 *prop-constant* nil
|
||||
(syntoken "'''" :nospec t :switch -1))
|
||||
(syntable :string *prop-string* nil
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\"" :nospec t :switch -1))
|
||||
(syntable :string3 *prop-string* nil
|
||||
(syntoken "\"\"\"" :nospec t :switch -1))
|
||||
)
|
166
app/xedit/lisp/modules/progmodes/rpm.lsp
Normal file
166
app/xedit/lisp/modules/progmodes/rpm.lsp
Normal file
|
@ -0,0 +1,166 @@
|
|||
;;
|
||||
;; Copyright (c) 2003 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/rpm.lsp,v 1.1 2003/01/16 03:50:46 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
;; Only for testing, unifinished, good for viewing but too slow for real use...
|
||||
#|
|
||||
(defsynprop *prop-rpm-special*
|
||||
"rpm-special"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "NavyBlue"
|
||||
)
|
||||
|
||||
(defsynprop *prop-rpm-escape*
|
||||
"rpm-escape"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "Red3")
|
||||
|
||||
;; main package is implicit
|
||||
(defsyntax *rpm-mode* :package nil nil nil
|
||||
(syntable :sections nil nil
|
||||
(syntoken "^%package"
|
||||
:icase t
|
||||
:switch :package
|
||||
;; XXX :begin :package was added just to test finishing and
|
||||
;; starting a new syntax-table, unfortunately if using it
|
||||
;; this way, frequently the entire file will be reparsed
|
||||
;; at every character typed.
|
||||
;; TODO study these cases and implement code to avoid it,
|
||||
;; the easiest way is limiting the number of backtracked lines,
|
||||
;; the screen contents sometimes could not correctly reflect
|
||||
;; file contents in this case...
|
||||
:begin :package
|
||||
:property *prop-rpm-special*)
|
||||
(syntoken "^%(build|setup|install|pre|preun|post|postun)\\>"
|
||||
:icase t
|
||||
:property *prop-rpm-special*
|
||||
:switch :package
|
||||
:begin :shell)
|
||||
;; %changelog, XXX no rules to return to the toplevel
|
||||
(syntoken "^%changelog\\>"
|
||||
:icase t
|
||||
:switch :package
|
||||
:begin :changelog
|
||||
:property *prop-rpm-special*)
|
||||
(syntable :changelog nil nil
|
||||
;; ignore if escaped
|
||||
(syntoken "%%")
|
||||
;; "warn" if not escaped
|
||||
(syntoken "%" :property *prop-control*)
|
||||
;; emails
|
||||
(syntoken "<[a-z0-9_-]+@[a-z0-9_-]+\\.\\w+(\\.\\w+)?>"
|
||||
:icase t
|
||||
:property *prop-string*)
|
||||
)
|
||||
;; comments
|
||||
(syntoken "#" :contained t :nospec t :begin :comment)
|
||||
(syntable :comment *prop-comment* nil
|
||||
;; some macros are expanded even when inside comments, and may
|
||||
;; cause surprises, "warn" about it
|
||||
(syntoken "%\\{?\\w+\\}?" :property *prop-rpm-special*)
|
||||
(syntoken "$" :switch -1)
|
||||
)
|
||||
(synaugment :global)
|
||||
)
|
||||
|
||||
;; may appear anywhere
|
||||
(syntable :global nil nil
|
||||
;; preprocessor like commands
|
||||
(syntoken "^%(define|if|ifarch|else|endif)\\>"
|
||||
:icase t
|
||||
:property *prop-preprocessor*)
|
||||
;; variables
|
||||
(syntoken "%\\{.*\\}" :property *prop-constant*)
|
||||
)
|
||||
|
||||
;; example: "Group: ..." or "Group(pt_BR): ..."
|
||||
(syntoken "^\\w+(\\(\\w+\\))?:" :property *prop-keyword*)
|
||||
|
||||
;; for sections with shell commands
|
||||
(syntable :shell nil nil
|
||||
(syntoken "\\<(if|then|elif|else|fi|for|do|done|case|esac|while|until)\\>"
|
||||
:property *prop-keyword*)
|
||||
(syntable :strings nil nil
|
||||
(syntoken "\"" :nospec t :begin :string :contained t)
|
||||
(syntable :string *prop-string* nil
|
||||
(syntoken "\\$\\(?\\w+\\)?" :property *prop-constant*)
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\"" :nospec t :switch -1)
|
||||
)
|
||||
(syntoken "\'" :nospec t :begin :constant :contained t)
|
||||
(syntable :constant *prop-constant* nil
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\'" :nospec t :switch -1)
|
||||
)
|
||||
(syntoken "\`" :nospec t :begin :escape :contained t)
|
||||
(syntable :escape *prop-rpm-escape* nil
|
||||
(syntoken "\\$\\(?\\w+\\)?" :property *prop-constant*)
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\`" :nospec t :switch -1)
|
||||
)
|
||||
)
|
||||
(synaugment :strings :sections)
|
||||
)
|
||||
(synaugment :sections)
|
||||
)
|
||||
|#
|
||||
|
||||
|
||||
(defsyntax *rpm-mode* :package nil nil nil
|
||||
;; commands, macro definitions, etc
|
||||
(syntoken "^\\s*%\\s*\\w+" :property *prop-keyword*)
|
||||
|
||||
;; rpm "variables"
|
||||
(syntoken "%\\{.*\\}" :property *prop-constant*)
|
||||
|
||||
;; package info, example: "Group: ...", "Group(pt_BR): ...", etc.
|
||||
(syntoken "^\\w+(\\(\\w+\\))?:" :property *prop-preprocessor*)
|
||||
|
||||
;; comments
|
||||
(syntoken "#" :contained t :nospec t :begin :comment)
|
||||
(syntable :comment *prop-comment* nil
|
||||
;; some macros are expanded even when inside comments, and may
|
||||
;; cause surprises, "warn" about it
|
||||
(syntoken "%define\\>" :property *prop-control*)
|
||||
(syntoken "%\\{?\\w+\\}?" :property *prop-string*)
|
||||
(syntoken "$" :switch -1)
|
||||
)
|
||||
|
||||
;; emails
|
||||
(syntoken "<?[a-z0-9_-]+@[a-z0-9_-]+\\.\\w+(\\.\\w+)*>?"
|
||||
:icase t
|
||||
:property *prop-string*)
|
||||
;; links
|
||||
(syntoken "\\<(http|ftp)://\\S+" :property *prop-string*)
|
||||
)
|
428
app/xedit/lisp/modules/progmodes/sgml.lsp
Normal file
428
app/xedit/lisp/modules/progmodes/sgml.lsp
Normal file
|
@ -0,0 +1,428 @@
|
|||
;;
|
||||
;; Copyright (c) 2002 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/sgml.lsp,v 1.2 2002/10/06 17:11:48 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
;; Default property the text is shown.
|
||||
(defsynprop *prop-sgml-default*
|
||||
"default"
|
||||
:font "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10"
|
||||
)
|
||||
|
||||
(defsynprop *prop-sgml-default-short*
|
||||
"default-short"
|
||||
:font "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10"
|
||||
:underline t
|
||||
)
|
||||
|
||||
;; Large font.
|
||||
(defsynprop *prop-sgml-sect*
|
||||
"sect"
|
||||
:font "-*-helvetica-bold-r-*-*-17-*-*-*-*-*-*-1"
|
||||
:foreground "Gray20"
|
||||
)
|
||||
|
||||
;; Monospaced property.
|
||||
(defsynprop *prop-sgml-tt*
|
||||
"tt"
|
||||
:font "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Black"
|
||||
)
|
||||
|
||||
;; Italic property.
|
||||
(defsynprop *prop-sgml-it*
|
||||
"it"
|
||||
:font "-*-helvetica-medium-o-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Black"
|
||||
)
|
||||
|
||||
;; Bold font property.
|
||||
(defsynprop *prop-sgml-bf*
|
||||
"bf"
|
||||
:font "-*-helvetica-bold-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10"
|
||||
)
|
||||
|
||||
;; Looks like a link...
|
||||
(defsynprop *prop-sgml-link*
|
||||
"link"
|
||||
:font "-*-helvetica-medium-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "blue"
|
||||
:underline t
|
||||
)
|
||||
|
||||
;; Monospaced, also looks like a link...
|
||||
(defsynprop *prop-sgml-email*
|
||||
"email"
|
||||
:font "-*-courier-medium-r-*-*-12-*-*-*-*-*-*-1"
|
||||
:foreground "blue"
|
||||
:underline t
|
||||
)
|
||||
|
||||
;; Another monospaced property,
|
||||
(defsynprop *prop-sgml-screen*
|
||||
"screen"
|
||||
:font "-*-fixed-*-*-*-*-*-*-*-*-*-*-*-1"
|
||||
:foreground "Gray10"
|
||||
)
|
||||
|
||||
(defsynprop *prop-sgml-maybe-entity*
|
||||
"maybe-entity"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "VioletRed4"
|
||||
:background "LightYellow"
|
||||
)
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; The macros sgml-syntoken and sgml-syntable allows creating rules for
|
||||
;; matching text inside tags in the format:
|
||||
;; <tag> or <tag arg=value> or <tag arg1=value ... argn=value>
|
||||
;; any-text
|
||||
;; </tag>
|
||||
;; The generated rules don't allow things like: < tag> or </tag >
|
||||
;;
|
||||
;; This could also be done as a normal definition, with a starting rule like:
|
||||
;; "<(tag1|tag2|tag3)\\>"
|
||||
;; and an ending rule like:
|
||||
;; "</(tag1|tag2|tag3)>"
|
||||
;; But is implemented in way that will fail on purpose for things like:
|
||||
;; <tag1>any text</tag3></tag1>
|
||||
;;
|
||||
;; NOTE: These definitions aren't cheap in the time required to process the
|
||||
;; file, and are just adaptations/tests with the syntax-highlight code,
|
||||
;; probably it is better to avoid using it in other syntax definitions.
|
||||
;; NOTE2: It cannot be defined as a single macro because it is required to
|
||||
;; generate 2 entries in the main SGML syntax highlight definition,
|
||||
;; or, should generate the entire definition from a macro; you will
|
||||
;; need to type the tag name twice, but shouldn't be a problem if
|
||||
;; you are using sgml :-)
|
||||
;; XXX: Maybe the syntax-highlight code could save the starting match and
|
||||
;; apply a regex generated at run-time to check for the ending tag,
|
||||
;; but this probably would make the parser too slow, better to have
|
||||
;; a specialized parser if that is required...
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defmacro sgml-syntoken (name)
|
||||
`(syntoken (string-concat "<" ,name "\\>")
|
||||
:icase t
|
||||
:contained t
|
||||
:begin (intern (string-concat ,name "$") 'keyword))
|
||||
)
|
||||
(defmacro sgml-syntable (name property)
|
||||
`(let
|
||||
(
|
||||
(label (intern (string-concat ,name "$") 'keyword))
|
||||
(nested-label (intern (string (gensym)) 'keyword))
|
||||
)
|
||||
(syntable label *prop-preprocessor* nil
|
||||
;; tag is still open, process any options
|
||||
(synaugment :generic-tag)
|
||||
(syntoken ">"
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:begin nested-label)
|
||||
;; Generate a nested table that includes everything, and only
|
||||
;; returns when the closing tag is found.
|
||||
(syntable nested-label ,property nil
|
||||
(syntoken (string-concat "</" ,name ">")
|
||||
:icase t
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:switch -2)
|
||||
(synaugment :main)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Generate tokens for tags that don't require and ending tag.
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defmacro sgml-syntable-simple (name property)
|
||||
`(let
|
||||
(
|
||||
(label (intern (string-concat ,name "$") 'keyword))
|
||||
(nested-label (intern (string (gensym)) 'keyword))
|
||||
)
|
||||
(syntable label *prop-preprocessor* nil
|
||||
;; tag is still open, process any options
|
||||
(synaugment :generic-tag)
|
||||
(syntoken ">"
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:begin nested-label)
|
||||
;; Generate a nested table that finishes whenever an unmatched
|
||||
;; start or end tag is found.
|
||||
(syntable nested-label ,property nil
|
||||
(syntoken "</"
|
||||
:icase t
|
||||
:nospec t
|
||||
:contained t
|
||||
:begin :simple-nested-tag)
|
||||
;; These will take precedence over other rules
|
||||
(syntoken "<"
|
||||
:icase t
|
||||
:nospec t
|
||||
:contained t
|
||||
:begin :simple-nested-tag)
|
||||
(syntoken "<p>"
|
||||
:icase t
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:switch :main)
|
||||
(synaugment :main)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Define some macros to generate tokens for tags in the format:
|
||||
;; <tag/ ... /
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
(defmacro sgml-syntoken-short (name)
|
||||
`(syntoken (string-concat "<" ,name "/")
|
||||
:icase t
|
||||
:property *prop-preprocessor*
|
||||
:begin (intern (string-concat ,name "/") 'keyword))
|
||||
)
|
||||
(defmacro sgml-syntable-short (name property)
|
||||
`(syntable (intern (string-concat ,name "/") 'keyword) ,property nil
|
||||
(syntoken "/"
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:switch -1)
|
||||
(syntoken "</?\\w+>"
|
||||
:property *prop-control*
|
||||
:switch :main)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
;; The main SGML syntax table
|
||||
(defsyntax *sgml-mode* :main *prop-sgml-default* nil nil
|
||||
;; Comments
|
||||
(syntoken "<!--"
|
||||
:nospec t
|
||||
:contained t
|
||||
:begin :comment)
|
||||
(syntable :comment *prop-comment* nil
|
||||
;; Only one rule, to finish the comment.
|
||||
(syntoken "-->"
|
||||
:nospec t
|
||||
:switch -1)
|
||||
)
|
||||
|
||||
;; Entities
|
||||
(syntoken "&[a-zA-Z0-9_.-]+;"
|
||||
:property *prop-constant*)
|
||||
;; Probably an entity, missing ending `;'
|
||||
(syntoken "&[a-zA-Z0-9_.-]+"
|
||||
:property *prop-sgml-maybe-entity*)
|
||||
|
||||
;; Strings
|
||||
(syntable :string *prop-string* nil
|
||||
;; Ignore escaped characters.
|
||||
(syntoken "\\\\.")
|
||||
;; Rule to finish the string.
|
||||
(syntoken "\""
|
||||
:nospec t
|
||||
:switch -1)
|
||||
)
|
||||
|
||||
;; Links
|
||||
(syntable :link *prop-preprocessor* nil
|
||||
;; No link string following "url="
|
||||
(syntoken ">"
|
||||
:nospec t
|
||||
:property *prop-control*
|
||||
:switch -1)
|
||||
(syntoken "\""
|
||||
:nospec t
|
||||
:contained t
|
||||
:begin :link-string)
|
||||
(syntable :link-string *prop-sgml-link* nil
|
||||
;; Ignore escaped characters.
|
||||
(syntoken "\\\\.")
|
||||
;; Rule to finish the link, note that returns two levels.
|
||||
(syntoken "\""
|
||||
:nospec t
|
||||
:switch -2)
|
||||
)
|
||||
)
|
||||
|
||||
;; "Special" tag
|
||||
(syntoken "<!"
|
||||
:nospec t
|
||||
:contained t
|
||||
:begin :special-tag)
|
||||
;; Rules for "special" tags
|
||||
(syntable :special-tag *prop-preprocessor* nil
|
||||
(syntoken "["
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:begin :brackets)
|
||||
;; Finish the "special" tag
|
||||
(syntoken ">"
|
||||
:nospec t
|
||||
:switch -1)
|
||||
(syntable :brackets *prop-sgml-default* nil
|
||||
(syntoken "]"
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:switch -1)
|
||||
;; Allow nesting.
|
||||
(syntoken "["
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:begin :brackets)
|
||||
;; Entities.
|
||||
(syntoken "%[a-zA-Z0-9_.-]+;?"
|
||||
:property *prop-annotation*)
|
||||
;; Allow everything inside the brackets
|
||||
(synaugment :main)
|
||||
)
|
||||
;; Don't use generic tag tokens, only create a rule for strings
|
||||
(syntoken "\""
|
||||
:nospec t
|
||||
:begin :string
|
||||
:contained t)
|
||||
;; Allow everything inside the "special" tag
|
||||
(synaugment :main)
|
||||
)
|
||||
|
||||
;; Some "short" tags
|
||||
(sgml-syntoken-short "tt")
|
||||
(sgml-syntable-short "tt" *prop-sgml-tt*)
|
||||
(sgml-syntoken-short "it")
|
||||
(sgml-syntable-short "it" *prop-sgml-it*)
|
||||
(sgml-syntoken-short "bf")
|
||||
(sgml-syntable-short "bf" *prop-sgml-bf*)
|
||||
(sgml-syntoken-short "em")
|
||||
(sgml-syntable-short "em" *prop-sgml-bf*)
|
||||
|
||||
;; Short tag
|
||||
(syntoken "<\\w+/"
|
||||
:property *prop-preprocessor*
|
||||
:begin :short-tag)
|
||||
(syntable :short-tag *prop-sgml-default-short* nil
|
||||
(syntoken "/"
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:switch -1)
|
||||
(syntoken "</?\\w+>"
|
||||
:property *prop-control*
|
||||
:switch -1)
|
||||
)
|
||||
|
||||
;; Don't allow spaces, this may and may not be the start of a tag,
|
||||
;; but the syntax-highlight definition is not specialized...
|
||||
(syntoken "<([^/a-zA-Z]|$)"
|
||||
:property *prop-control*)
|
||||
|
||||
;; Some tags that require an end tag
|
||||
(sgml-syntoken "tt")
|
||||
(sgml-syntable "tt" *prop-sgml-tt*)
|
||||
(sgml-syntoken "code")
|
||||
(sgml-syntable "code" *prop-sgml-tt*)
|
||||
(sgml-syntoken "tag")
|
||||
(sgml-syntable "tag" *prop-sgml-tt*)
|
||||
(sgml-syntoken "verb")
|
||||
(sgml-syntable "verb" *prop-sgml-tt*)
|
||||
(sgml-syntoken "programlisting")
|
||||
(sgml-syntable "programlisting" *prop-sgml-tt*)
|
||||
(sgml-syntoken "it")
|
||||
(sgml-syntable "it" *prop-sgml-it*)
|
||||
(sgml-syntoken "bf")
|
||||
(sgml-syntable "bf" *prop-sgml-bf*)
|
||||
(sgml-syntoken "em")
|
||||
(sgml-syntable "em" *prop-sgml-bf*)
|
||||
(sgml-syntoken "mail")
|
||||
(sgml-syntable "mail" *prop-sgml-email*)
|
||||
(sgml-syntoken "email")
|
||||
(sgml-syntable "email" *prop-sgml-email*)
|
||||
(sgml-syntoken "screen")
|
||||
(sgml-syntable "screen" *prop-sgml-screen*)
|
||||
(sgml-syntoken "tscreen")
|
||||
(sgml-syntable "tscreen" *prop-sgml-screen*)
|
||||
|
||||
|
||||
;; Helper for tags that don't need an ending one.
|
||||
;; NOTE: Since the parser is not specialized, if the tag is
|
||||
;; folowed by one that has a special property defined here,
|
||||
;; it may not be detected, i.e. put a <p> after the <sect>
|
||||
;; and it will work.
|
||||
(syntable :simple-nested-tag *prop-preprocessor* nil
|
||||
;; tag is still open, process any options
|
||||
(synaugment :generic-tag)
|
||||
(syntoken ">"
|
||||
:nospec t
|
||||
:property *prop-preprocessor*
|
||||
:switch -3)
|
||||
)
|
||||
(sgml-syntoken "sect")
|
||||
(sgml-syntable-simple "sect" *prop-sgml-sect*)
|
||||
(sgml-syntoken "sect1")
|
||||
(sgml-syntable-simple "sect1" *prop-sgml-sect*)
|
||||
(sgml-syntoken "sect2")
|
||||
(sgml-syntable-simple "sect2" *prop-sgml-sect*)
|
||||
|
||||
;; Generic tags
|
||||
(syntoken "<"
|
||||
:nospec t
|
||||
:contained t
|
||||
:begin :tag)
|
||||
;; Table :generic-tag is defined to be augmented, no rule to finish it.
|
||||
(syntable :generic-tag *prop-preprocessor* nil
|
||||
;; Start string
|
||||
(syntoken "\""
|
||||
:nospec t
|
||||
:begin :string
|
||||
:contained t)
|
||||
;; Start url link
|
||||
(syntoken "url="
|
||||
:nospec t
|
||||
:begin :link)
|
||||
;; Cannot nest
|
||||
(syntoken "<"
|
||||
:nospec t
|
||||
:property *prop-control*)
|
||||
)
|
||||
(syntable :tag *prop-preprocessor* nil
|
||||
;; Finish the tag
|
||||
(syntoken ">"
|
||||
:nospec t
|
||||
:switch -1)
|
||||
;; Import generic definitions
|
||||
(synaugment :generic-tag)
|
||||
)
|
||||
)
|
113
app/xedit/lisp/modules/progmodes/sh.lsp
Normal file
113
app/xedit/lisp/modules/progmodes/sh.lsp
Normal file
|
@ -0,0 +1,113 @@
|
|||
;;
|
||||
;; Copyright (c) 2003 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/sh.lsp,v 1.1 2003/01/16 03:50:46 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(require "indent")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-escape*
|
||||
"escape"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "Red3")
|
||||
|
||||
(defsynprop *prop-variable*
|
||||
"variable"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "Gold4")
|
||||
|
||||
(defsynprop *prop-backslash*
|
||||
"backslash"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "green4")
|
||||
|
||||
;; XXX it would be interesting if "here-documents" could be parsed
|
||||
;; just searching for "<<\s*EOF\\>" and then for "^EOF\\>" should
|
||||
;; handle most cases, but would be a hack...
|
||||
(defsyntax *sh-mode* :main nil #'default-indent nil
|
||||
;; keywords and common commands/builtins
|
||||
(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)\\>"
|
||||
:property *prop-keyword*)
|
||||
|
||||
; comments
|
||||
(syntoken "#.*$" :property *prop-comment*)
|
||||
|
||||
;; punctuation
|
||||
(syntoken "[][;:*?(){}<>&!|$#]+" :property *prop-punctuation*)
|
||||
|
||||
;; variable declaration
|
||||
(syntoken "\\w+=" :property *prop-preprocessor*)
|
||||
|
||||
;; numbers
|
||||
(syntoken "\\<\\d+\\>" :property *prop-number*)
|
||||
|
||||
;; escaped characters at toplevel
|
||||
(syntoken "\\\\." :property *prop-backslash*)
|
||||
|
||||
;; single quote
|
||||
(syntoken "'" :nospec t :contained t :begin :single)
|
||||
(syntable :single *prop-constant* nil
|
||||
;; do nothing, escaped characters
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "'" :nospec t :switch -1)
|
||||
)
|
||||
|
||||
;; double quote
|
||||
(syntoken "\"" :nospec t :contained t :begin :double)
|
||||
(syntable :double *prop-string* #'default-indent
|
||||
;; escaped characters
|
||||
(syntoken "\\\\." :property *prop-backslash*)
|
||||
(syntoken "\"" :nospec t :switch -1)
|
||||
;; rule to start escape
|
||||
(syntoken "`" :nospec t :contained t :begin :escape)
|
||||
;; ignore single quote, required because escape is augmented
|
||||
(syntoken "'" :nospec t)
|
||||
(synaugment :escape :variable)
|
||||
)
|
||||
|
||||
;; escaped commands
|
||||
(syntoken "`" :nospec t :contained t :begin :escape)
|
||||
(syntable :escape *prop-escape* #'default-indent
|
||||
;; escaped characters
|
||||
(syntoken "\\\\." :property *prop-backslash*)
|
||||
(syntoken "`" :nospec t :switch -1)
|
||||
;; rule to start double quote inside escape
|
||||
(syntoken "\"" :nospec t :contained t :begin :double)
|
||||
;; rule to start single quote
|
||||
(syntoken "'" :nospec t :contained t :begin :single)
|
||||
(synaugment :double :variable)
|
||||
)
|
||||
|
||||
(syntable :variable nil nil
|
||||
(syntoken "\\$\\w+" :property *prop-variable*)
|
||||
)
|
||||
(synaugment :variable)
|
||||
)
|
68
app/xedit/lisp/modules/progmodes/xconf.lsp
Normal file
68
app/xedit/lisp/modules/progmodes/xconf.lsp
Normal file
|
@ -0,0 +1,68 @@
|
|||
;;
|
||||
;; Copyright (c) 2003 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86$
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(require "indent")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsyntax *xconf-mode* :main nil #'default-indent nil
|
||||
;; section start
|
||||
(syntoken "\\<(Section|SubSection)\\>"
|
||||
:property *prop-keyword* :icase t :begin :section)
|
||||
;; just for fun, highlight the section name differently
|
||||
(syntable :section *prop-constant* #'default-indent
|
||||
(syntoken "\"" :nospec t :begin :name)
|
||||
(syntable :name *prop-constant* nil
|
||||
;; ignore escaped characters
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\"" :nospec t :switch -2)
|
||||
)
|
||||
)
|
||||
|
||||
;; section end
|
||||
(syntoken "\\<(EndSection|EndSubSection)\\>"
|
||||
:property *prop-keyword* :icase t)
|
||||
|
||||
;; numeric options
|
||||
(syntoken "\\<\\d+(\\.\\d+)?\\>" :property *prop-number*)
|
||||
|
||||
;; comments
|
||||
(syntoken "#.*$" :property *prop-comment*)
|
||||
|
||||
;; strings
|
||||
(syntoken "\"" :nospec t :begin :string :contained t)
|
||||
(syntable :string *prop-string* #'default-indent
|
||||
;; ignore escaped characters
|
||||
(syntoken "\\\\.")
|
||||
(syntoken "\"" :nospec t :switch -1)
|
||||
)
|
||||
)
|
102
app/xedit/lisp/modules/progmodes/xlog.lsp
Normal file
102
app/xedit/lisp/modules/progmodes/xlog.lsp
Normal file
|
@ -0,0 +1,102 @@
|
|||
;;
|
||||
;; Copyright (c) 2003 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/xlog.lsp,v 1.1 2003/01/16 06:25:51 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-xlog-probe*
|
||||
"xlog-probe"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:background "rgb:c/f/c")
|
||||
|
||||
(defsynprop *prop-xlog-config*
|
||||
"xlog-config"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:background "rgb:c/e/f")
|
||||
|
||||
(defsynprop *prop-xlog-default*
|
||||
"xlog-default"
|
||||
:font "*courier-medium-r*-12-*"
|
||||
:background "rgb:e/c/f")
|
||||
|
||||
(defsynprop *prop-xlog-warning*
|
||||
"xlog-warning"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "Red4"
|
||||
:background "Yellow1"
|
||||
)
|
||||
|
||||
(defsynprop *prop-xlog-error*
|
||||
"xlog-error"
|
||||
:font "*courier-bold-r*-12-*"
|
||||
:foreground "Yellow2"
|
||||
:background "Red3"
|
||||
)
|
||||
|
||||
(defsyntax *xlog-mode* :main nil nil nil
|
||||
;; highlight version
|
||||
(syntoken "^XFree86 Version \\S+" :property *prop-annotation*)
|
||||
|
||||
;; release date
|
||||
(syntoken "^Release Date: " :property *prop-keyword* :begin :note)
|
||||
|
||||
;; highlight operating system description
|
||||
(syntoken "^Build Operating System: " :property *prop-keyword* :begin :note)
|
||||
|
||||
(syntable :note *prop-annotation* nil (syntoken "$" :switch -1))
|
||||
|
||||
;; don't highlight info lines
|
||||
(syntoken "^\\(II\\) " :property *prop-keyword*)
|
||||
|
||||
;; default lines
|
||||
(syntoken "^\\(==\\) " :property *prop-keyword* :begin :default)
|
||||
(syntable :default *prop-xlog-default* nil (syntoken "$" :switch -1))
|
||||
|
||||
;; probe lines
|
||||
(syntoken "^\\(--\\) " :property *prop-keyword* :begin :probe)
|
||||
(syntable :probe *prop-xlog-probe* nil (syntoken "$" :switch -1))
|
||||
|
||||
;; config lines
|
||||
(syntoken "^\\(\\*\\*\\) " :property *prop-keyword* :begin :config)
|
||||
(syntable :config *prop-xlog-config* nil (syntoken "$" :switch -1))
|
||||
|
||||
;; warnings
|
||||
(syntoken "^\\(WW\\) " :property *prop-keyword* :begin :warning)
|
||||
(syntable :warning *prop-xlog-warning* nil (syntoken "$" :switch -1))
|
||||
|
||||
;; errors
|
||||
(syntoken "^\\(EE\\) " :property *prop-keyword* :begin :error)
|
||||
(syntable :error *prop-xlog-error* nil (syntoken "$" :switch -1))
|
||||
|
||||
;; command line and "uncommon" messages
|
||||
(syntoken "^\\(..\\) " :property *prop-control* :begin :warning)
|
||||
)
|
115
app/xedit/lisp/modules/progmodes/xrdb.lsp
Normal file
115
app/xedit/lisp/modules/progmodes/xrdb.lsp
Normal file
|
@ -0,0 +1,115 @@
|
|||
;;
|
||||
;; Copyright (c) 2002 by The XFree86 Project, Inc.
|
||||
;;
|
||||
;; Permission is hereby granted, free of charge, to any person obtaining a
|
||||
;; copy of this software and associated documentation files (the "Software"),
|
||||
;; to deal in the Software without restriction, including without limitation
|
||||
;; the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
;; and/or sell copies of the Software, and to permit persons to whom the
|
||||
;; Software is furnished to do so, subject to the following conditions:
|
||||
;;
|
||||
;; The above copyright notice and this permission notice shall be included in
|
||||
;; all copies or substantial portions of the Software.
|
||||
;;
|
||||
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
;; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
;; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
;; THE XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
;; WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
||||
;; OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
;; SOFTWARE.
|
||||
;;
|
||||
;; Except as contained in this notice, the name of the XFree86 Project shall
|
||||
;; not be used in advertising or otherwise to promote the sale, use or other
|
||||
;; dealings in this Software without prior written authorization from the
|
||||
;; XFree86 Project.
|
||||
;;
|
||||
;; Author: Paulo César Pereira de Andrade
|
||||
;;
|
||||
;;
|
||||
;; $XFree86: xc/programs/xedit/lisp/modules/progmodes/xrdb.lsp,v 1.2 2002/10/06 17:11:48 paulo Exp $
|
||||
;;
|
||||
|
||||
(require "syntax")
|
||||
(in-package "XEDIT")
|
||||
|
||||
(defsynprop *prop-xrdb-comment*
|
||||
"xrdb-comment"
|
||||
:font "*courier-medium-o*-12-*"
|
||||
:foreground "sienna"
|
||||
)
|
||||
|
||||
(defsynprop *prop-xrdb-special*
|
||||
"format"
|
||||
:font "*lucidatypewriter-medium-r*-12-*"
|
||||
:foreground "RoyalBlue4"
|
||||
)
|
||||
|
||||
(defsynprop *prop-xrdb-punctuation*
|
||||
"punctuation"
|
||||
:font "-*-courier-bold-r-*-*-14-*-*-*-*-*-*-1"
|
||||
:foreground "OrangeRed4"
|
||||
)
|
||||
|
||||
(defsyntax *xrdb-mode* :main nil nil nil
|
||||
(syntoken "^\\s*!.*"
|
||||
:property *prop-xrdb-comment*)
|
||||
(syntoken "^\\s*#.*"
|
||||
:property *prop-preprocessor*)
|
||||
(syntoken "\\*|\\.|\\?"
|
||||
:property *prop-xrdb-punctuation*
|
||||
:begin :resource)
|
||||
(syntoken "."
|
||||
:nospec t
|
||||
:begin :resource)
|
||||
|
||||
;; Extra comments
|
||||
(syntoken "/*" :nospec t :begin :comment :contained t)
|
||||
(syntable :comment *prop-comment* nil
|
||||
(syntoken "/*" :nospec t :property *prop-error*)
|
||||
;; Rule to finish a comment.
|
||||
(syntoken "*/" :nospec t :switch -1)
|
||||
)
|
||||
|
||||
(syntable :resource nil nil
|
||||
(syntoken "\\*|\\.|\\?" :property *prop-xrdb-punctuation*)
|
||||
(syntoken ":\\s*" :property *prop-xrdb-punctuation* :begin :value)
|
||||
)
|
||||
|
||||
(syntable :value *prop-string* nil
|
||||
(syntoken "\\\\$" :property *prop-constant*)
|
||||
|
||||
|
||||
;; If the pattern ends at a newline, must switch to the previous state.
|
||||
;; Not sure yet how to better handle this. The parser does not detect
|
||||
;; eol because it is a match to the empty string. A possible hack
|
||||
;; would be to check if the pattern string ends in a "$", but probably
|
||||
;; better in this case to have a syntoken option, to tell the parser
|
||||
;; an eol may exist.
|
||||
(syntoken
|
||||
(string-concat
|
||||
"("
|
||||
"\\d+|" ;; numbers
|
||||
"(#\\x+|rgb:\\x+/\\x+/\\x+)|" ;; color spec
|
||||
"#\\w+" ;; translation table
|
||||
")$")
|
||||
:property *prop-xrdb-special* :switch -2)
|
||||
(syntoken "(\\\\n?|\")$"
|
||||
:property *prop-constant* :switch -2)
|
||||
|
||||
;; XXX Cut&paste of the above, only without the match to eol
|
||||
(syntoken
|
||||
(string-concat
|
||||
"("
|
||||
"\\d+|"
|
||||
"(#\\x+|rgb:\\x+/\\x+/\\x+)|"
|
||||
"#\\w+"
|
||||
")")
|
||||
:property *prop-xrdb-special*)
|
||||
(syntoken "(\\\\n?|\")"
|
||||
:property *prop-constant*)
|
||||
|
||||
(syntoken "/*" :nospec t :begin :comment :contained t)
|
||||
(syntoken ".?$" :switch -2)
|
||||
)
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue