1
0
Fork 0
mirror of git://git.psyced.org/git/psyclpc synced 2024-08-15 03:20:16 +00:00

initial git creation

This commit is contained in:
PSYC 2009-03-03 04:27:01 +01:00
commit 2ede0de60e
278 changed files with 230984 additions and 0 deletions

14
etc/README Normal file
View file

@ -0,0 +1,14 @@
Miscellaneous files for the driver:
lpc-mode.el : LPC mode for EMACS, by Vivek Dasmohapatra <vivek@etla.org>
lpc.xml : LPC syntax highlighting for Kate, by <Andreas.Klauer@epost.de>
lpc.vim : LPC syntax highlighting for vim, maintained by Shizhu
Pan <poet@mudbuilder.net>
savefile-parse.pl: A perl snippet which reads a LPMud savefile and
transforms it into a Perl datastructure.
The following scripts are just working examples - use them to roll your own:
memusage : A script to analyze OBJ_DUMP.

382
etc/lpc-mode.el Normal file
View file

@ -0,0 +1,382 @@
;; LPC mode
;;
;; Emacs Lisp Archive Entry
;; Package: lpc-mode
;; Filename: lpc-mode.el
;; Version: 0.12
;; Keywords: languages, LPC
;; Author: Vivek Dasmohapatra <vivek@etla.org>
;; Maintainer: Vivek Dasmohapatra <vivek@etla.org>
;; Created: 2002-08-31
;; Description: syntax highlighting/indentation for LPC
;; URL: http://rtfm.etla.org/emacs/lpc-mode/
;; Compatibility: Emacs21
;; Last-Updated: Tue 2002-09-17 23:59:51 +0100
;; This file is NOT part of GNU Emacs
;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program; if not, write to the Free Software
;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
;; Copyright (C) 2002 Vivek Dasmohapatra <vivek@etla.org>
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2 of the License, or
;; (at your option) any later version.
;; OK Nick: first stab at LPC mode:
;; 0.01: 'foo and 'C' should be handled correctly.
;; 0.02 ... 0.06: intermediates.
;; 0.07: ultra-hairy ({#'[][,&] syntax now scanned for. Bleurgh.
;; 0.08: ({ ... }) syntax added as brace-list
;; 0.09: rip up and rewrite as a proper cc-mode based mode
;; 0.10: miscellaneous bugfixes.
;; 0.11: should compile cleanly now _and_ work as well (I hope)
;; 0.12: bug in `lpc-font-lock-map' keyword/function definition highlighting
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HOW TO INSTALL:
;;
;; ;; either put lpc-mode.el in your load path and use:
;; (autoload 'lpc-mode "lpc-mode" t)
;;
;; ;; or have:
;; (autoload 'lpc-mode "/path/to/lpc-mode.el" t)
;;
;; ;; then:
;; (setq auto-mode-alist
;; (append '(("\\.lpc$" . lpc-mode)) auto-mode-alist)) )
;;
;; Nick: You'll have to do similar things to handler.el to get that to
;; work, let me know if you need this done.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; elisp-dep-block >>
(require 'custom );(defface)
(require 'cc-mode );(c-electric-brace)
(require 'regexp-opt);(regexp-opt-depth regexp-opt)
(require 'font-lock )
;;(font-lock-add-keywords font-lock-fontify-region font-lock-mode)
;; elisp-dep-block <<
(defconst lpc-mode-version "0.12")
(eval-and-compile
(defmacro lpc-defsyntax (name doc klist)
"Declare a cc-mode syntax variable of lpc-N-keywords and a regex
lpc-N-regex to go along with it, based on the keyword list K."
(let* ((n name )
(d doc )
(k klist)
(ln (format "lpc-%s-keywords" n))
(ld (format "%s (list)" d))
(ls (intern ln))
(rn (format "lpc-%s-regex" n))
(rd (format "%s (regex)" d))
(rs (intern rn))
(kwds nil))
(setq kwds (if (stringp (car k)) k (eval k)))
;;(message "%s" (format "%S" kwds))
`(progn (defconst ,ls ',kwds ,ld)
(defconst ,rs (regexp-opt ',kwds) ,rd)) ))
(lpc-defsyntax type
"LPC primitive type keywords."
("int" "mapping" "mixed" "object" "status" "string" "void"))
(lpc-defsyntax specifier
"LPC declaration specifier keywords."
("nomask" "private" "public" "static" "varargs"))
(lpc-defsyntax other-decl
"LPC keywords starting other decl-level constructs."
("inherit"))
(lpc-defsyntax block-stmt-1
"LPC keywords followed directly by a block."
("do" "else"))
(lpc-defsyntax block-stmt-2
"LPC keywords followed by a paren sexp and then by a block."
("for" "if" "switch" "while" "foreach"))
(lpc-defsyntax simple-stmt
"LPC statement keywords followed by an expression or nothing."
("break" "continue" "return"))
(lpc-defsyntax label
"LPC keywords introducing labels in blocks."
("case" "default"))
(lpc-defsyntax all
"LPC keywords."
(append lpc-type-keywords
lpc-specifier-keywords
lpc-other-decl-keywords
lpc-block-stmt-1-keywords
lpc-block-stmt-2-keywords
lpc-simple-stmt-keywords
lpc-label-keywords ))
(lpc-defsyntax default-highlight
"LPC keywords (for default highlighting)"
(append lpc-specifier-keywords
lpc-block-stmt-1-keywords
lpc-block-stmt-2-keywords
lpc-simple-stmt-keywords ))
(lpc-defsyntax conditional
"LPC conditional keywords"
(append lpc-block-stmt-1-keywords lpc-block-stmt-2-keywords))
)
(defconst lpc-comment-start-regex c-C++-comment-start-regexp)
(defconst lpc-special-brace-lists '((?{ . ?})) )
(defconst lpc-magic-quote-comma '(9))
(defconst lpc-magic-symbol-name '(3))
(defvar lpc-mode-syntax-table nil)
(if lpc-mode-syntax-table
nil
(setq lpc-mode-syntax-table (make-syntax-table))
(c-populate-syntax-table lpc-mode-syntax-table)
(modify-syntax-entry ?\' "'" lpc-mode-syntax-table) )
(defun lpc-modify-syntax-at (beg end syntax)
"Apply a syntax-property value syntax from beg to end."
(if (<= (point-max) end) nil; noop
(progn
;;(message "(%d x %d) => %S" beg end syntax)
(put-text-property beg end 'syntax-table syntax)
(put-text-property (1- end) end 'rear-nonsticky t ))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Code by Seth Golub <seth AT cs DOT wustl DOT edu>, 1996-02-01,
;; no licence.
;;
;; modified slightly to bring this up to date, didn't work quite right
;; out of the box:
(defun lpc-maybe-electric-brace (arg)
"Insert character and maybe correct line's indentation."
(interactive "P")
(if (= last-command-char ?{)
(if (= (preceding-char) ?\()
(self-insert-command (prefix-numeric-value arg))
(c-electric-brace arg))
;; (= last-command-char ?})
(let (start-point state containing-sexp)
(save-excursion (beginning-of-defun)
(setq start-point (point)))
(save-excursion (setq state (parse-partial-sexp (point) start-point 0)))
(setq containing-sexp (car (cdr state)))
(if (and containing-sexp (save-excursion
(goto-char (1- containing-sexp))
(looking-at "(")))
(progn
(self-insert-command (prefix-numeric-value arg))
(lpc-scan-magic-quote))
(c-electric-brace arg)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defconst lpc-magic-quote-regex "({\\s-*#'\\([^\\s-\n,}]+\\|,\\)\\s-*[,}]")
(defun lpc-magic-comma-p (pt)
(let ((bol nil) (eol nil) (pos nil) (ret nil))
(save-excursion
(goto-char pt)
(end-of-line)
(setq eol (point))
(beginning-of-line)
(setq bol (point))
(while (and (not ret)
(setq pos (re-search-forward lpc-magic-quote-regex eol t)))
;;(message "magic pattern at %d/%d" (1- pos) pt)
(if (/= (1- pos) pt) nil
(setq ret (list (- (match-beginning 1) 1)
(match-beginning 1)
(match-end 1)
bol)) ) )) ret))
(defun lpc-scan-magic-quotes ()
(save-excursion
(let ((qpos nil) (wbeg nil) (wend nil))
(while (re-search-forward lpc-magic-quote-regex nil t)
(setq qpos (+ (match-beginning 0) 3)
wbeg (match-beginning 1)
wend (match-end 1))
(lpc-modify-syntax-at qpos (1+ qpos) lpc-magic-quote-comma)
(lpc-modify-syntax-at wbeg wend lpc-magic-symbol-name)
)
)
)
)
(defun lpc-scan-magic-quote ()
(save-excursion
(let ((coord nil) (qpos nil) (wbeg nil) (wend nil) (bol nil))
(if (setq coord (lpc-magic-comma-p (1- (point))))
(progn
(setq qpos (car coord)
wbeg (cadr coord)
wend (car (cddr coord))
bol (cadr (cddr coord)))
;;(message "magic pattern at (%d %d %d)" qpos wbeg wend)
(lpc-modify-syntax-at qpos (1+ qpos) lpc-magic-quote-comma)
(lpc-modify-syntax-at wbeg wend lpc-magic-symbol-name)
(font-lock-fontify-region bol wend) )
)
)
)
)
(defun lpc-maybe-quote-ref (arg)
"Kludge to work around multiple syntactic meanings of `,' `[' et al in LPC."
(interactive "P")
(self-insert-command (prefix-numeric-value arg))
(lpc-scan-magic-quote) )
(defvar lpc-mode-map nil "Keymap for LPC mode buffers.")
(if lpc-mode-map
nil
(setq lpc-mode-map (c-make-inherited-keymap))
(define-key lpc-mode-map "\C-c:" 'c-scope-operator)
(define-key lpc-mode-map "{" 'lpc-maybe-electric-brace)
(define-key lpc-mode-map "}" 'lpc-maybe-electric-brace)
(define-key lpc-mode-map "," 'lpc-maybe-quote-ref)
(define-key lpc-mode-map "\C-c\C-e" 'c-macro-expand)
)
(defvar lpc-mode-hook nil)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; font-lock support:
(defvar lpc-reference-face 'lpc-reference-face)
(defface lpc-reference-face
'((((class color) (background dark)) (:foreground "bisque" ))
(((class color) (background light)) (:foreground "dark blue")))
"LPC mode face for quoted symbols")
(defconst lpc-type-depth (regexp-opt-depth lpc-type-regex))
(defconst lpc-font-lock-map
(append
c-font-lock-keywords-1
(list
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; what follows is mostly ripped from font-lock.el, mostly...
`(eval . (cons (concat "\\<\\(" ,lpc-type-regex "\\)\\>")
'font-lock-type-face))
(concat "\\<\\(" lpc-default-highlight-regex "\\)\\>")
'("\\<\\(case\\)\\>" (1 font-lock-keyword-face)
("\\(-[0-9]+\\|\\sw+\\)"
;; Return limit of search.
(save-excursion (skip-chars-forward "^:\n") (point))
nil
(1 font-lock-constant-face nil t)))
'(":" ("^[ \t]*\\(\\sw+\\)[ \t]*:[ \t]*$"
(beginning-of-line) (end-of-line)
(1 font-lock-constant-face)))
`(eval . (list
(concat "\\<\\(" ,lpc-type-regex "\\)\\>"
"\\([ \t*&]+\\sw+\\>\\)*")
;; Fontify each declaration item.
(list
'font-lock-match-c-style-declaration-item-and-skip-to-next
;; Start with point after all type specifiers.
(list 'goto-char
(list 'or
(list 'match-beginning
(+ ,lpc-type-depth 2))
'(match-end 1)))
;; Finish with point after first type specifier.
'(goto-char (match-end 1))
;; Fontify as a variable or function name.
'(1 (if (match-beginning 2)
font-lock-function-name-face
font-lock-variable-name-face)))))
;; Fontify anything at beginning of line as a declaration or definition.
'("^\\(\\sw+\\)\\>\\([ \t*]+\\sw+\\>\\)*"
(1 font-lock-type-face)
(font-lock-match-c-style-declaration-item-and-skip-to-next
(goto-char (or (match-beginning 2) (match-end 1))) nil
(1 (if (match-beginning 2)
font-lock-function-name-face
font-lock-variable-name-face))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; and now native LPC highlighting:
'("\\('.'\\|'\\\\.'\\)" 1 font-lock-string-face keep)
;; lambda thingies
'("{\\s-*\\(#\\)" 1 font-lock-builtin-face keep)
'("'\\([^}, \t;]+\\)" 1 lpc-reference-face keep)
'("'\\(,\\)[,} \t\n]" 1 lpc-reference-face keep)
;;
'("\\(\\binherit\\)\\s-+\\s\".+\";" 1 font-lock-builtin-face t)
)
)
)
(defun lpc-set-font-lock-defaults ()
"Set up LPC mode font-lock stuff."
(let ((font-lock-defaults '(lpc-font-lock-map
nil
nil
((?_ . "w") (?\' . "'"))
beginning-of-defun
(font-lock-mark-block-function . mark-defun))))
(font-lock-set-defaults)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; bring it all together:
(defun lpc-mode ()
(interactive)
(c-initialize-cc-mode)
(kill-all-local-variables)
(set-syntax-table lpc-mode-syntax-table)
(make-variable-buffer-local 'parse-sexp-lookup-properties)
(set 'parse-sexp-lookup-properties t)
(setq major-mode 'lpc-mode
mode-name "LPC")
(use-local-map lpc-mode-map)
(c-common-init)
(setq c-keywords (c-identifier-re lpc-all-regex)
c-special-brace-lists lpc-special-brace-lists
comment-start "// "
comment-end ""
c-conditional-key lpc-conditional-regex
c-comment-start-regexp lpc-comment-start-regex
c-extra-toplevel-key lpc-other-decl-regex
;; c-class-key nil ;; cannot set this to nil or ""
c-method-key nil
c-baseclass-key nil
c-recognize-knr-p nil
c-lambda-key nil
c-inexpr-block-key nil
c-inexpr-class-key nil)
(lpc-set-font-lock-defaults)
(lpc-scan-magic-quotes)
(if (not noninteractive)
(turn-on-font-lock)
(let ((font-lock-mode t) (noninteractive nil))
(turn-on-font-lock)))
(run-hooks 'c-mode-common-hook)
(run-hooks 'lpc-mode-hook)
(c-update-modeline)
)
(provide 'lpc-mode)
;; lpc-mode.el ends here

447
etc/lpc.vim Normal file
View file

@ -0,0 +1,447 @@
" Vim syntax file
" Language: LPC
" Maintainer: Shizhu Pan <poet@mudbuilder.net>
" URL: http://poet.tomud.com/pub/lpc.vim.bz2
" Last Change: 2003 May 11
" Comments: If you are using Vim 6.2 or later, see :h lpc.vim for
" file type recognizing, if not, you had to use modeline.
" Changed for LDMud 3.2 and 3.3, Coogan@Tubmud, 02-Sep-2003
" Nodule: This is the start nodule. {{{1
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
" Nodule: Keywords {{{1
" LPC keywords
" keywords should always be highlighted so "contained" is not used.
syn cluster lpcKeywdGrp contains=lpcConditional,lpcLabel,lpcOperator,lpcRepeat,lpcStatement,lpcModifier,lpcReserved
syn keyword lpcConditional if else switch
syn keyword lpcLabel case default
syn keyword lpcOperator catch efun in inherit nolog publish
syn keyword lpcRepeat do for foreach while
syn keyword lpcStatement break continue return function
syn match lpcEfunError /efun[^:]/ display
" Illegal to use keyword as function
" It's not working, maybe in the next version.
syn keyword lpcKeywdError contained if for foreach return switch while
" These are keywords only because they take lvalue or type as parameter,
" so these keywords should only be used as function but cannot be names of
" user-defined functions.
" syn keyword lpcKeywdFunc new parse_command sscanf time_expression
" Nodule: Type and modifiers {{{1
" Type names list.
" Special types
syn keyword lpcType void mixed unknown
" Scalar/Value types.
syn keyword lpcType int float string status
" Pointer types.
syn keyword lpcType array function mapping object struct
" Other types.
syn keyword lpcType closure funcall
" Type modifier.
syn keyword lpcModifier nomask private public
syn keyword lpcModifier varargs virtual
" sensible modifiers
syn keyword lpcModifier nosave protected static
" Nodule: Applies {{{1
" Match a function declaration or function pointer
syn match lpcApplyDecl excludenl /->\h\w*(/me=e-1 contains=lpcApplies transparent display
" We should note that in func_spec.c the efun definition syntax is so
" complicated that I use such a long regular expression to describe.
syn match lpcLongDecl excludenl /\(\s\|\*\)\h\+\s\h\+(/me=e-1 contains=@lpcEfunGroup,lpcType,@lpcKeywdGrp transparent display
" this is form for all functions
" ->foo() form had been excluded
syn match lpcFuncDecl excludenl /\h\w*(/me=e-1 contains=lpcApplies,@lpcEfunGroup,lpcKeywdError transparent display
" The (: :) parenthesis or $() forms a function pointer
syn match lpcFuncName /(:\s*\h\+\s*:)/me=e-1 contains=lpcApplies,@lpcEfunGroup transparent display contained
syn match lpcFuncName /(:\s*\h\+,/ contains=lpcApplies,@lpcEfunGroup transparent display contained
syn match lpcFuncName /\$(\h\+)/ contains=lpcApplies,@lpcEfunGroup transparent display contained
" Applies list.
" system applies for compat mode
syn keyword lpcApplies contained add_weight can_put_and_get drop get prevent_insert query_weight
" system applies for native mode
syn keyword lpcApplies contained create
" system applies
syn keyword lpcApplies contained __INIT catch_msg clean_up exit heart_beat id init reset
" interactive
syn keyword lpcApplies contained catch_tell logon modify_command
" master applies
syn keyword lpcApplies contained compile_object connect creator_file dangling_lfun_closure disconnect epilog external_master_reload flag get_bb_uid get_ed_buffer_save_file_name get_master_uid get_simul_efun get_wiz_name heart_beat_error inaugurate_master include_file inherit_file log_error make_path_absolute notify_shutdown preload prepare_destruct printf_obj_name privilege_violation query_allow_shadow quota_demon reactivate_destructed_master receive_imp receive_udp remove_player retrieve_ed_setup runtime_error save_ed_setup slow_shutdown stale_erq
syn keyword lpcApplies contained valid_exec valid_query_snoop valid_read valid_seteuid valid_snoop valid_trace valid_write
" parsing
syn keyword lpcApplies contained parse_command_adjectiv_id_list parse_command_all_word parse_command_id_list parse_command_plural_id_list parse_command_prepos_list
" Nodule: Efuns {{{1
syn cluster lpcEfunGroup contains=lpc_efuns,lpcOldEfuns,lpcNewEfuns,lpcKeywdFunc,lpcCompatEfuns,lpcNativeEfuns,lpcSimulEfuns
" syn match lpcErrFunc /#`\h\w*/
" Shell compatible first line comment.
" syn region lpcCommentFunc start=/^#!/ end=/$/
" efuns which are [to be] removed in newer versions of LDMud.
syn keyword lpcOldEfuns contained add_verb add_xverb allocate_mapping copy_mapping efun308 file_name filter_array filter_mapping m_sizeof map_array map_mapping mapping_contains member_array parse_command query_imp_port send_imp set_auto_include_string transfer
" new efuns of LDMud 3.3
syn keyword lpcNewEfuns contained baseof call_direct call_direct_resolved match_command md5_crypt regmatch
syn keyword lpcNewEfuns contained start_mccp_compress end_mccp_compress query_mccp query_mccp_stats
syn keyword lpcNewEfuns contained pg_connect pg_query pg_pending pg_close
syn keyword lpcNewEfuns contained struct_info structp to_struct
syn keyword lpcNewEfuns contained tls_query_connection_state tls_query_connection_info tls_init_connection tls_deinit_connection tls_error
syn keyword lpcCompatEfuns contained creator
syn keyword lpcNativeEfuns contained export_uid geteuid getuid seteuid
" simul efuns, add your simul efuns here
syn keyword lpcSimulEfuns contained transfer
" LPC efuns list.
" Efuns list {{{2
syn keyword lpc_efuns contained abs acos add_action all_environment all_inventory allocate allocate_mapping and_bits apply asin assoc atan atan2 attach_erq_demon
syn keyword lpc_efuns contained binary_message bind_lambda blueprint break_point
syn keyword lpc_efuns contained call_other call_out call_out_info call_resolved caller_stack caller_stack_depth capitalize cat catch ceil clear_bit clone_object clonep clones closurep command command_stack command_stack_depth copy copy_bits copy_file cos count_bits crypt ctime
syn keyword lpc_efuns contained db_affected_rows db_close db_coldefs db_connect db_conv_string db_error db_exec db_fetch db_handles db_insert_id debug_info debug_message deep_copy deep_inventory destruct disable_commands
syn keyword lpc_efuns contained ed enable_commands environment exec execute_command exp expand_define explode extern_call extract
syn keyword lpc_efuns contained file_size filter filter_indices filter_objects find_call_out find_input_to find_object first_inventory floatp floor funcall function_exists functionlist
syn keyword lpc_efuns contained garbage_collection get_dir get_error_file get_eval_cost get_extra_wizinfo get_type_info gmtime
syn keyword lpc_efuns contained heart_beat_info
syn keyword lpc_efuns contained implode include_list inherit_list input_to input_to_info insert_alist interactive intersect_alist intp invert_bits
syn keyword lpc_efuns contained lambda last_bit last_instructions limited living load_name load_object localtime log lower_case
syn keyword lpc_efuns contained m_add m_allocate m_contains m_delete m_entry m_indices m_reallocate m_values make_shared_string map map_indices map_objects mappingp max md5 member min mkdir mkmapping move_object
syn keyword lpc_efuns contained negate next_bit next_inventory notify_fail
syn keyword lpc_efuns contained object_info object_name object_time objectp or_bits order_alist
syn keyword lpc_efuns contained pointerp pow present present_clone previous_object printf process_string program_name program_time
syn keyword lpc_efuns contained query_actions query_command query_editing query_idle query_input_pending query_ip_name query_ip_number query_limits query_load_average query_mud_port query_notify_fail query_once_interactive query_shadowing query_snoop query_udp_port query_verb quote
syn keyword lpc_efuns contained raise_error random read_bytes read_file referencep regexp regexplode regmatch regreplace remove_action remove_call_out remove_input_to remove_interactive rename rename_object replace_program restore_object restore_value rm rmdir rmember rusage
syn keyword lpc_efuns contained save_object save_value say send_erq send_udp set_bit set_buffer_size set_combine_charset set_connection_charset set_driver_hook set_environment set_extra_wizinfo set_extra_wizinfo_size set_heart_beat set_is_wizard set_light set_limits set_modify_command set_next_reset set_prompt set_this_object set_this_player sgn shadow shutdown sin sizeof slice_array snoop sort_array sprintf sqrt sscanf stringp strlen strrstr strstr swap symbol_function symbol_variable symbolp
syn keyword lpc_efuns contained tail tan tell_object tell_room terminal_colour test_bit this_interactive this_object this_player throw time to_array to_float to_int to_object to_string trace traceprefix transpose_array trim typeof
syn keyword lpc_efuns contained unbound_lambda unique_array unmkmapping unquote unshadow upper_case users utime
syn keyword lpc_efuns contained variable_exists variable_list
syn keyword lpc_efuns contained walk_mapping widthof wizlist_info write write_bytes write_file
syn keyword lpc_efuns contained xor_bits
" Nodule: Constants {{{1
" LPC Constants.
" like keywords, constants are always highlighted, be careful to choose only
" the constants we used to add to this list.
syn keyword lpcConstant LPC3 __LDMUD__ __EUIDS__ COMPAT_FLAG __COMPAT_MODE__ __STRICT_EUIDS__ __FILENAME_SPACES__ __MASTER_OBJECT__ __FILE__ __LINE__ __DIR__ __PATH__ __VERSION__ __VERSION_MAJOR__ __VERSION_MINOR__ __VERSION_MICRO__ __VERSION_PATCH__ __DOMAIN_NAME__ __HOST_IP_NUMBER__ __HOST_NAME__ __MAX_RECURSION__ __MAX_EVAL_COST__ __CATCH_EVAL_COST__ __MASTER_EVAL_COST__ __RESET_TIME__ __CLEANUP_TIME__ __EFUN_DEFINED__ __DRIVER_LOG__ __WIZLIST__ __INT_MAX__ __INT_MIN__ __FLOAT_MAX__ __FLOAT_MIN__ __MAX_MALLOC__
" Nodule: Todo for this file. {{{1
" TODO : need to check for LPC4 syntax and other series of LPC besides
" v22, b21 and l32, if you had a good idea, contact me at poet@mudbuilder.net
" and I will be appreciated about that.
" Notes about some FAQ:
"
" About variables : We adopts the same behavior for C because almost all the
" LPC programmers are also C programmers, so we don't need separate settings
" for C and LPC. That is the reason why I don't change variables like
" "c_no_utf"s to "lpc_no_utf"s.
"
" Copy : Some of the following seems to be copied from c.vim but not quite
" the same in details because the syntax for C and LPC is different.
"
" Color scheme : this syntax file had been thouroughly tested to work well
" for all of the dark-backgrounded color schemes Vim has provided officially,
" and it should be quite Ok for all of the bright-backgrounded color schemes,
" of course it works best for the color scheme that I am using, download it
" from http://poet.tomud.com/pub/ps_color.vim.bz2 if you want to try it.
"
" Nodule: String and Character {{{1
" String and Character constants
" Highlight special characters (those which have a backslash) differently
syn match lpcSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
if !exists("c_no_utf")
syn match lpcSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)"
endif
" LPC version of sprintf() format,
syn match lpcFormat display "%\(\d\+\)\=[-+ |=#@:.]*\(\d\+\)\=\('\I\+'\|'\I*\\'\I*'\)\=[OsdicoxXf]" contained
syn match lpcFormat display "%%" contained
syn region lpcString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=lpcSpecial,lpcFormat
" lpcCppString: same as lpcString, but ends at end of line
syn region lpcCppString start=+L\="+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end='$' contains=lpcSpecial,lpcFormat
" LPC preprocessor for the text formatting short cuts
" Thanks to Dr. Charles E. Campbell <cec@gryphon.gsfc.nasa.gov>
" he suggests the best way to do this.
syn region lpcTextString start=/@\z(\h\w*\)$/ end=/^\z1/ contains=lpcSpecial
syn region lpcArrayString start=/@@\z(\h\w*\)$/ end=/^\z1/ contains=lpcSpecial
" Character
syn match lpcCharacter "L\='[^\\]'"
syn match lpcCharacter "L'[^']*'" contains=lpcSpecial
syn match lpcSpecialError "L\='\\[^'\"?\\abefnrtv]'"
syn match lpcSpecialCharacter "L\='\\['\"?\\abefnrtv]'"
syn match lpcSpecialCharacter display "L\='\\\o\{1,3}'"
syn match lpcSpecialCharacter display "'\\x\x\{1,2}'"
syn match lpcSpecialCharacter display "L'\\x\x\+'"
" Nodule: White space {{{1
" when wanted, highlight trailing white space
if exists("c_space_errors")
if !exists("c_no_trail_space_error")
syn match lpcSpaceError display excludenl "\s\+$"
endif
if !exists("c_no_tab_space_error")
syn match lpcSpaceError display " \+\t"me=e-1
endif
endif
" Nodule: Parenthesis and brackets {{{1
" catch errors caused by wrong parenthesis and brackets
syn cluster lpcParenGroup contains=lpcParenError,lpcIncluded,lpcSpecial,lpcCommentSkip,lpcCommentString,lpcComment2String,@lpcCommentGroup,lpcCommentStartError,lpcUserCont,lpcUserLabel,lpcBitField,lpcCommentSkip,lpcOctalZero,lpcCppOut,lpcCppOut2,lpcCppSkip,lpcFormat,lpcNumber,lpcFloat,lpcOctal,lpcOctalError,lpcNumbersCom
syn region lpcParen transparent start='(' end=')' contains=ALLBUT,@lpcParenGroup,lpcCppParen,lpcErrInBracket,lpcCppBracket,lpcCppString,@lpcEfunGroup,lpcApplies,lpcKeywdError
" lpcCppParen: same as lpcParen but ends at end-of-line; used in lpcDefine
syn region lpcCppParen transparent start='(' skip='\\$' excludenl end=')' end='$' contained contains=ALLBUT,@lpcParenGroup,lpcErrInBracket,lpcParen,lpcBracket,lpcString,@lpcEfunGroup,lpcApplies,lpcKeywdError
syn match lpcParenError display ")"
syn match lpcParenError display "\]"
" for LPC:
" Here we should consider the array ({ }) parenthesis and mapping ([ ])
" parenthesis and multiset (< >) parenthesis.
syn match lpcErrInParen display contained "[^^]{"ms=s+1
syn match lpcErrInParen display contained "\(}\|\]\)[^)]"me=e-1
syn region lpcBracket transparent start='\[' end=']' contains=ALLBUT,@lpcParenGroup,lpcErrInParen,lpcCppParen,lpcCppBracket,lpcCppString,@lpcEfunGroup,lpcApplies,lpcFuncName,lpcKeywdError
" lpcCppBracket: same as lpcParen but ends at end-of-line; used in lpcDefine
syn region lpcCppBracket transparent start='\[' skip='\\$' excludenl end=']' end='$' contained contains=ALLBUT,@lpcParenGroup,lpcErrInParen,lpcParen,lpcBracket,lpcString,@lpcEfunGroup,lpcApplies,lpcFuncName,lpcKeywdError
syn match lpcErrInBracket display contained "[);{}]"
" Nodule: Numbers {{{1
" integer number, or floating point number without a dot and with "f".
syn case ignore
syn match lpcNumbers display transparent "\<\d\|\.\d" contains=lpcNumber,lpcFloat,lpcOctalError,lpcOctal
" Same, but without octal error (for comments)
syn match lpcNumbersCom display contained transparent "\<\d\|\.\d" contains=lpcNumber,lpcFloat,lpcOctal
syn match lpcNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
" hex number
syn match lpcNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
" Flag the first zero of an octal number as something special
syn match lpcOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=lpcOctalZero
syn match lpcOctalZero display contained "\<0"
syn match lpcFloat display contained "\d\+f"
" floating point number, with dot, optional exponent
syn match lpcFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\=[fl]\="
" floating point number, starting with a dot, optional exponent
syn match lpcFloat display contained "\.\d\+\(e[-+]\=\d\+\)\=[fl]\=\>"
" floating point number, without dot, with exponent
syn match lpcFloat display contained "\d\+e[-+]\=\d\+[fl]\=\>"
" flag an octal number with wrong digits
syn match lpcOctalError display contained "0\o*[89]\d*"
syn case match
" Nodule: Comment string {{{1
" lpcCommentGroup allows adding matches for special things in comments
syn keyword lpcTodo contained TODO FIXME XXX
syn cluster lpcCommentGroup contains=lpcTodo
if exists("c_comment_strings")
" A comment can contain lpcString, lpcCharacter and lpcNumber.
syntax match lpcCommentSkip contained "^\s*\*\($\|\s\+\)"
syntax region lpcCommentString contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end=+\*/+me=s-1 contains=lpcSpecial,lpcCommentSkip
syntax region lpcComment2String contained start=+L\=\\\@<!"+ skip=+\\\\\|\\"+ end=+"+ end="$" contains=lpcSpecial
syntax region lpcCommentL start="//" skip="\\$" end="$" keepend contains=@lpcCommentGroup,lpcComment2String,lpcCharacter,lpcNumbersCom,lpcSpaceError
syntax region lpcComment matchgroup=lpcCommentStart start="/\*" matchgroup=NONE end="\*/" contains=@lpcCommentGroup,lpcCommentStartError,lpcCommentString,lpcCharacter,lpcNumbersCom,lpcSpaceError
else
syn region lpcCommentL start="//" skip="\\$" end="$" keepend contains=@lpcCommentGroup,lpcSpaceError
syn region lpcComment matchgroup=lpcCommentStart start="/\*" matchgroup=NONE end="\*/" contains=@lpcCommentGroup,lpcCommentStartError,lpcSpaceError
endif
" keep a // comment separately, it terminates a preproc. conditional
syntax match lpcCommentError display "\*/"
syntax match lpcCommentStartError display "/\*"me=e-1 contained
" Nodule: Pre-processor {{{1
syn region lpcPreCondit start="^\s*#\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=lpcComment,lpcCppString,lpcCharacter,lpcCppParen,lpcParenError,lpcNumbers,lpcCommentError,lpcSpaceError
syn match lpcPreCondit display "^\s*#\s*\(else\|endif\)\>"
if !exists("c_no_if0")
syn region lpcCppOut start="^\s*#\s*if\s\+0\+\>" end=".\|$" contains=lpcCppOut2
syn region lpcCppOut2 contained start="0" end="^\s*#\s*\(endif\>\|else\>\|elif\>\)" contains=lpcSpaceError,lpcCppSkip
syn region lpcCppSkip contained start="^\s*#\s*\(if\>\|ifdef\>\|ifndef\>\)" skip="\\$" end="^\s*#\s*endif\>" contains=lpcSpaceError,lpcCppSkip
endif
syn region lpcIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match lpcIncluded display contained "<[^>]*>"
syn match lpcInclude display "^\s*#\s*include\>\s*["<]" contains=lpcIncluded
syn match lpcLineSkip "\\$"
syn cluster lpcPreProcGroup contains=lpcPreCondit,lpcIncluded,lpcInclude,lpcDefine,lpcErrInParen,lpcErrInBracket,lpcUserLabel,lpcSpecial,lpcOctalZero,lpcCppOut,lpcCppOut2,lpcCppSkip,lpcFormat,lpcNumber,lpcFloat,lpcOctal,lpcOctalError,lpcNumbersCom,lpcString,lpcCommentSkip,lpcCommentString,lpcComment2String,@lpcCommentGroup,lpcCommentStartError,lpcParen,lpcBracket,lpcMulti,lpcKeywdError
syn region lpcDefine start="^\s*#\s*\(define\|undef\)\>" skip="\\$" end="$" end="//"me=s-1 contains=ALLBUT,@lpcPreProcGroup
if exists("lpc_pre_v22")
syn region lpcPreProc start="^\s*#\s*\(pragma\>\|echo\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@lpcPreProcGroup
else
syn region lpcPreProc start="^\s*#\s*\(pragma\>\|echo\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend contains=ALLBUT,@lpcPreProcGroup
endif
" Nodule: User labels {{{1
" Highlight Labels
" User labels in LPC is not allowed, only "case x" and "default" is supported
syn cluster lpcMultiGroup contains=lpcIncluded,lpcSpecial,lpcCommentSkip,lpcCommentString,lpcComment2String,@lpcCommentGroup,lpcCommentStartError,lpcUserCont,lpcUserLabel,lpcBitField,lpcOctalZero,lpcCppOut,lpcCppOut2,lpcCppSkip,lpcFormat,lpcNumber,lpcFloat,lpcOctal,lpcOctalError,lpcNumbersCom,lpcCppParen,lpcCppBracket,lpcCppString,lpcKeywdError
syn region lpcMulti transparent start='\(case\|default\|public\|protected\|private\)' skip='::' end=':' contains=ALLBUT,@lpcMultiGroup
syn cluster lpcLabelGroup contains=lpcUserLabel
syn match lpcUserCont display "^\s*lpc:$" contains=@lpcLabelGroup
" Don't want to match anything
syn match lpcUserLabel display "lpc" contained
" Nodule: Initializations {{{1
if exists("c_minlines")
let b:c_minlines = c_minlines
else
if !exists("c_no_if0")
let b:c_minlines = 50 " #if 0 constructs can be long
else
let b:c_minlines = 15 " mostly for () constructs
endif
endif
exec "syn sync ccomment lpcComment minlines=" . b:c_minlines
" Make sure these options take place since we no longer depend on file type
" plugin for C
setlocal cindent
setlocal fo-=t fo+=croql
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,://
set cpo-=C
" Win32 can filter files in the browse dialog
if has("gui_win32") && !exists("b:browsefilter")
let b:browsefilter = "LPC Source Files (*.c *.d *.h)\t*.c;*.d;*.h\n" .
\ "LPC Data Files (*.scr *.o *.dat)\t*.scr;*.o;*.dat\n" .
\ "Text Documentation (*.txt)\t*.txt\n" .
\ "All Files (*.*)\t*.*\n"
endif
" Nodule: Highlight links {{{1
" Define the default highlighting.
" For version 5.7 and earlier: only when not done already
" For version 5.8 and later: only when an item doesn't have highlighting yet
if version >= 508 || !exists("did_lpc_syn_inits")
if version < 508
let did_lpc_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink lpcModifier lpcStorageClass
HiLink lpcQuotedFmt lpcFormat
HiLink lpcFormat lpcSpecial
HiLink lpcCppString lpcString " Cpp means
" C Pre-Processor
HiLink lpcCommentL lpcComment
HiLink lpcCommentStart lpcComment
HiLink lpcUserLabel lpcLabel
HiLink lpcSpecialCharacter lpcSpecial
HiLink lpcOctal lpcPreProc
HiLink lpcOctalZero lpcSpecial " LPC will treat octal numbers
" as decimals, programmers should
" be aware of that.
HiLink lpcEfunError lpcError
HiLink lpcKeywdError lpcError
HiLink lpcOctalError lpcError
HiLink lpcParenError lpcError
HiLink lpcErrInParen lpcError
HiLink lpcErrInBracket lpcError
HiLink lpcCommentError lpcError
HiLink lpcCommentStartError lpcError
HiLink lpcSpaceError lpcError
HiLink lpcSpecialError lpcError
HiLink lpcErrFunc lpcError
" HiLink lpcOldEfuns lpc_efuns
HiLink lpcOldEfuns lpcReserved
HiLink lpcNewEfuns lpcFunction
HiLink lpcCompatEfuns lpcFunction
HiLink lpcNativeEfuns lpcFunction
HiLink lpcSimulEfuns lpcFunction
HiLink lpc_efuns lpcFunction
HiLink lpcReserved lpcPreProc
HiLink lpcTextString lpcString " This should be preprocessors, but
HiLink lpcArrayString lpcPreProc " let's make some difference
" between text and array
HiLink lpcIncluded lpcString
HiLink lpcCommentString lpcString
HiLink lpcComment2String lpcString
HiLink lpcCommentSkip lpcComment
HiLink lpcCommentFunc lpcComment
HiLink lpcCppSkip lpcCppOut
HiLink lpcCppOut2 lpcCppOut
HiLink lpcCppOut lpcComment
" Standard type below
HiLink lpcApplies Special
HiLink lpcCharacter Character
HiLink lpcComment Comment
HiLink lpcConditional Conditional
HiLink lpcConstant Constant
HiLink lpcDefine Macro
HiLink lpcError Error
HiLink lpcFloat Float
HiLink lpcFunction Function
HiLink lpcIdentifier Identifier
HiLink lpcInclude Include
HiLink lpcLabel Label
HiLink lpcNumber Number
HiLink lpcOperator Operator
HiLink lpcPreCondit PreCondit
HiLink lpcPreProc PreProc
HiLink lpcRepeat Repeat
HiLink lpcStatement Statement
HiLink lpcStorageClass StorageClass
HiLink lpcString String
HiLink lpcStructure Structure
HiLink lpcSpecial LineNr
HiLink lpcTodo Todo
HiLink lpcType Type
delcommand HiLink
endif
" Nodule: This is the end nodule. {{{1
let b:current_syntax = "lpc"
" vim:ts=8:nosta:sw=2:ai:si:
" vim600:set fdm=marker: }}}1

152
etc/lpc.xml Normal file
View file

@ -0,0 +1,152 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE language SYSTEM "language.dtd">
<!--
=============================================================================
File: lpc.xml
URL: http://www.metamorpher.de/files/lpc.xml
Description: Syntax Highlighting for Lars Pensjo C (LPC)
It is used in Multi User Dungeons which use LDMud as Gamedriver.
For more information, see LDMud project: http://www.bearnip.com
For best highlighting results, configure colors yourself.
Author: Andreas Klauer (Andreas.Klauer@metamorpher.de)
Changed: 2004-04-26
=============================================================================
-->
<language name="LPC" version="0.72" kateversion="2.2.1"
section="Sources" extensions="*.c;*.h;*.inc;*.o">
<highlighting>
<!-- Keyword Lists: -->
<list name="modifiers">
<item> private </item>
<item> protected </item>
<item> static </item>
<item> public </item>
<item> nomask </item>
<item> varargs </item>
<item> nosave </item>
<item> virtual </item>
</list>
<list name="types">
<item> void </item>
<item> int </item>
<item> status </item>
<item> string </item>
<item> object </item>
<item> array </item>
<item> mapping </item>
<item> closure </item>
<item> symbol </item>
<item> float </item>
<item> mixed </item>
</list>
<list name="keywords">
<item> break </item>
<item> continue </item>
<item> return </item>
<item> if </item>
<item> else </item>
<item> for </item>
<item> foreach </item>
<item> do </item>
<item> while </item>
<item> switch </item>
<item> case </item>
<item> inherit </item>
<item> default </item>
<item> variables </item>
<item> functions </item>
<item> publish </item>
<item> nolog </item>
</list>
<!-- Parsing Rules: -->
<contexts>
<context name="Normal" attribute="Default" lineEndContext="#stay">
<Detect2Chars attribute="Single-Line comments" context="Comment1" char="/" char1="/" />
<Detect2Chars attribute="Multi-Line comments" context="Comment2" char="/" char1="*" />
<keyword String="modifiers" attribute="Modifiers" context="#stay" />
<keyword String="types" attribute="Datatype" context="#stay" />
<keyword String="keywords" attribute="Keywords" context="#stay" />
<RegExpr String="^#" context="Preprocessor" attribute="Preprocessor" />
<Float attribute="Floats" context="#stay">
<AnyChar String="fFeE" context="#stay" />
</Float>
<RegExpr String="0b[01]+" attribute="Binary" context="#stay" />
<RegExpr String="0x[0-9a-fA-F]+" attribute="Hexadecimal" context="#stay" />
<RegExpr String="0o[0-7]+" attribute="Octal" context="#stay" />
<Int attribute="Integer" context="#stay" />
<RegExpr String="#'[^\t ][^\t ,);}\]/]*" attribute="Closure" context="#stay" />
<DetectChar attribute="Strings" context="String1" char="&quot;" />
<HlCStringChar attribute="Char" context="#stay" />
</context>
<context name="Comment1" attribute="Single-Line comments" lineEndContext="#pop">
<LineContinue attribute="Single-Line comments" context="#stay" />
<RegExpr attribute="Comment-Keywords" context="#stay" String="^[A-Z]+:" />
</context>
<context name="Comment2" attribute="Multi-Line comments" lineEndContext="#stay">
<Detect2Chars attribute="Multi-Line comments" context="#pop" char="*" char1="/"/>
<RegExpr attribute="Comment-Keywords" context="#stay" String="^[A-Z]+:" />
</context>
<context name="Preprocessor" attribute="Preprocessor" lineEndContext="#pop">
<LineContinue attribute="Preprocessor" context="#stay" />
<Detect2Chars attribute="Single-Line comments" context="Comment1" char="/" char1="/" />
<Detect2Chars attribute="Multi-Line comments" context="Comment2" char="/" char1="*" />
<keyword String="modifiers" attribute="Modifier" context="#stay" />
<keyword String="types" attribute="Datatype" context="#stay" />
<keyword String="keywords" attribute="Keywords" context="#stay" />
<DetectChar attribute="Preprocessor-Strings" context="String2" char="&quot;" />
</context>
<context name="String1" attribute="Strings" lineEndContext="#pop">
<LineContinue attribute="Default" context="#stay" />
<Detect2Chars char="\" char1="\" attribute="Strings" context="#stay" />
<Detect2Chars char="\" char1="&quot;" attribute="Strings" context="#stay" />
<DetectChar char="&quot;" attribute="Strings" context="#pop" />
</context>
<context name="String2" attribute="Preprocessor-Strings" lineEndContext="#pop">
<LineContinue attribute="Default" context="#stay" />
<Detect2Chars char="\" char1="\" attribute="Preprocessor-Strings" context="#stay" />
<Detect2Chars char="\" char1="&quot;" attribute="Preprocessor-Strings" context="#stay" />
<DetectChar char="&quot;" attribute="Preprocessor-Strings" context="#pop" />
</context>
</contexts>
<!-- Color Settings: -->
<itemDatas>
<itemData name="Default" defStyleNum="dsNormal" />
<itemData name="Single-Line comments" defStyleNum="dsComment" />
<itemData name="Multi-Line comments" defStyleNum="dsComment" />
<itemData name="Comment-Keywords" defStyleNum="dsKeyword" />
<itemData name="Modifier" defStyleNum="dsDataType" />
<itemData name="Datatype" defStyleNum="dsDataType" />
<itemData name="Keywords" defStyleNum="dsKeyword" />
<itemData name="Preprocessor" defStyleNum="dsOthers" />
<itemData name="Floats" defStyleNum="dsFloat" />
<itemData name="Binary" defStyleNum="dsBaseN" />
<itemData name="Hexadecimal" defStyleNum="dsBaseN" />
<itemData name="Octal" defStyleNum="dsBaseN" />
<itemData name="Integer" defStyleNum="dsDecVal" />
<itemData name="Closure" defStyleNum="dsOthers" />
<itemData name="Strings" defStyleNum="dsString" />
<itemData name="Preprocessor-Strings" defStyleNum="dsString" />
<itemData name="Char" defStyleNum="dsChar" />
</itemDatas>
</highlighting>
<!-- This is not for highlighting, but for detecting comments.
It allows Kate to hide comments if the user wished to do so. -->
<general>
<comments>
<comment name="singleLine" start="//" />
<comment name="multiLine" start="/*" end="*/" />
</comments>
<keywords casesensitive="1" />
</general>
</language>
<!-- === End of file. === -->

96
etc/memusage Executable file
View file

@ -0,0 +1,96 @@
#!/usr/bin/perl -w
# originating from MorgenGrauen
# 11.06.02 Fiona more robust parsing
$MUDLIBDIR = "/usr/mud/mudlib/";
$HOMES = "players";
$DOMAINS = "d";
$OUTPUTDIR = $MUDLIBDIR."tmp/";
$| = 1;
printf("Creating Object-Lists ... ");
%mem=(); %inst=(); %envs=(); %TotalMem=(); $MemSum=0;
%wizobj=();%wizmem=();%domobj=();%dommem=();
open(DUMP,$MUDLIBDIR."OBJ_DUMP");
for (<DUMP>)
{
chop;
#@line=split(' ');
print("matcherr: $_\n")
unless $_ =~ /^([^ ]+) \D*(\d+)\D*(\d+)\D*\d+ +(HB)? +(\S*)/;
$env=$5;
$env.=' *HB*' if ($4);
@fname=split('#',$1);
$mem{$1}=$2;
$inst{$fname[0]}+=1;
$TotalMem{$fname[0]}+=$2;
$envs{$1}=$5;
$MemSum+=$2;
@path=split("/",$1);
if ($path[0] eq $HOMES)
{
$wizobj{$path[1]}++;
$wizmem{$path[1]}+=$2;
}
if ($path[0] eq $DOMAINS)
{
$wizobj{$path[2]}++;
$wizmem{$path[2]}+=$2;
$domobj{$path[1]}++;
$dommem{$path[1]}+=$2;
}
}
printf("done\nMEMORY list is being created ... sorting ... ");
@keys=sort {$mem{$b} <=> $mem{$a}} keys %mem;
print "dumping ... ";
open(DUMP,">".$OUTPUTDIR."MEMORY_SORTED");
printf DUMP "Memory usage according to OBJ_DUMP is %d bytes.\n",$MemSum;
foreach $key (@keys)
{
printf DUMP "%-30s: mem=%4d, env=%s\n", $key, $mem{$key}, $envs{$key};
}
close(DUMP);
printf("done\nCOUNT_LIST is being created ... sorting ... ");
@keys=sort {$inst{$b} <=> $inst{$a}} keys %inst;
print "dumping ... ";
open(DUMP,">".$OUTPUTDIR."COUNT_SORTED");
foreach $key (@keys)
{
printf DUMP "%3d instances using %4d Bytes: %s\n",$inst{$key},$TotalMem{$key},$key;
}
close(DUMP);
printf("done\nTOTAL_MEM_LIST is being created ... sorting ... ");
@keys=sort {$TotalMem{$b} <=> $TotalMem{$a}} keys %inst;
print "dumping ... ";
open(DUMP,">".$OUTPUTDIR."TOTAL_MEM");
foreach $key (@keys)
{
printf DUMP "%3d instances using %4d Bytes: %s\n",$inst{$key},$TotalMem{$key},$key;
}
close(DUMP);
printf("done\nDumping OWNER list ... ");
@keys=sort {$wizmem{$b} <=> $wizmem{$a}} keys %wizmem;
open(DUMP,">".$OUTPUTDIR."BY_NAME");
printf DUMP "How much Memory does each Wizard use ?\n";
foreach $key (@keys)
{
printf DUMP "%-14s: %4d objects using %9d bytes\n", $key,$wizobj{$key},$wizmem{$key};
}
printf DUMP "\n\nHow much Memory does each domain use ?\n";
@keys=sort {$dommem{$b} <=> $dommem{$a}} keys %dommem;
foreach $key (@keys)
{
printf DUMP "%-14s: %4d objects using %9d bytes\n", $key,$domobj{$key},$dommem{$key};
}
close(DUMP);
print "done\n";

94
etc/psyclpc.ebuild Normal file
View file

@ -0,0 +1,94 @@
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /CVS/anonCVS/psyclpc/etc/psyclpc.ebuild,v 1.1 2007/08/14 09:03:30 lynx Exp $
#
# psyclpc is a programming language for intense multi-user network applications
# such as psyced. it's a recent fork of LDMUD with some features and many
# bug fixes. we kept it compatible to LDMUD, so you can run a MUD with it, too.
#
# Suggestions? tell psyc://psyced.org/~lynX
#
# WARNING/REMINDER to myself: When checking in a new version of this file
# into CVS I have to run 'make up' in the gentoo download tar, as it also
# relinks all the psyclpc/psyclpc-VERSION.ebuild files. 'cvs update' alone
# wouldn't do that.
#
# this ebuild file is available in both psyclpc/etc and psyced/config/gentoo.
# psyced also provides installation automations.
inherit toolchain-funcs eutils
DESCRIPTION="psycLPC is a multi-user network server programming language"
HOMEPAGE="http://lpc.psyc.eu/
# using the filename of the ebuild here!
# so better give it numbers which are actually
# available in http://www.psyced.org/files/
SRC_URI="http://www.psyced.org/files/${P}.tar.bz2"
LICENSE="GPL-2"
SLOT="0"
# haven't checked for real..
# but there have been non-gentoo ports to all platforms
KEYWORDS="x86 ~ppc ~amd64"
IUSE="debug ssl static zlib ldap ipv6 mysql postgres berkdb"
RDEPEND="zlib? ( sys-libs/zlib )
ssl? ( dev-libs/openssl )
ldap? ( net-nds/openldap )
berkdb? ( sys-libs/db )
mysql? ( dev-db/mysql )
postgres? ( dev-db/postgresql )"
DEPEND="${RDEPEND}
>=sys-devel/flex-2.5.4a-r5
>=sys-devel/bison-1.875
>=sys-devel/gettext-0.12.1"
#MYS="/var/tmp/portage/${P}/work/${P}/src"
MYS="${S}/src"
src_compile() {
cd "${MYS}"
# use berkdb >&/dev/null && myopts="${myopts} --enable-db"
# use mysql >&/dev/null && myopts="${myopts} --enable-mysql" || myopts="${myopts} --disable-mysql"
# use postgres >&/dev/null && myopts="${myopts} --enable-pgsql"
# use ldap >&/dev/null && myopts="${myopts} --enable-ldap"
# use ipv6 >&/dev/null && myopts="${myopts} --enable-ipv6"
use zlib && {
einfo "Compiling ${P} with zlib (MCCP) support."
myopts="${myopts} --enable-use-mccp"
}
use ssl && {
einfo "Compiling ${P} with SSL support."
myopts="${myopts} --enable-use-tls=yes"
}
use mysql && {
einfo "Compiling ${P} with mySQL support."
myopts="${myopts} --enable-use-mysql"
}
use postgres && {
einfo "Compiling ${P} with PostgreSQL support."
myopts="${myopts} --enable-use-pgsql"
}
use debug && {
append-flags -O -ggdb -DDEBUG
RESTRICT="${RESTRICT} nostrip"
myopts="${myopts} --enable-debug"
}
# runs configure
echo ${myopts}
# choice of settings should be configurable.. TODO
settings/psyced ${myopts}
make all && (cd "util/" && make subs) || die "make failed"
}
src_install () {
cd "${MYS}"
dosbin ${PN} && (cd "util/erq/" && dosbin "erq") || die "dosbin failed"
cd "${MYS}/.."
# only the interesting files
dodoc HELP CHANGELOG psyclpc.1
# maybe we should install etc/lpc.vim?
# and what about the man file?
}

209
etc/savefile-parse.pl Normal file
View file

@ -0,0 +1,209 @@
#!/usr/bin/perl -w
######
#
# Parse a mudmode (save_value) string
#
# A single variable value is parsed and represented as perl data structure.
# So a string like '({"a",3,(["b":2,]),})' gets ['a',3,{'b'=>2}]
#
# Fiona 23-Mai-03
#
use Data::Dumper;
$parse_err = undef; # Global error messages
%unquote = (
'r' => "\r",
'f' => "\f",
'v' => "\v",
'n' => "\n",
't' => "\t",
'b' => "\b",
'a' => "\a",
);
# parse a single value
#
# Knows: int, string, array, float, mapping
# (Todo: ref_to_array/mapping, closures)
#
# arguments: source string
# reference to start index of value
# returns value in perl
# set start index to next char (if any) or -1
#
# If an error occured -1 will be returned and $parse_err set
sub get_value {
my ($offsp, $str, $ret, $ret2, $data);
$str = $_[0];
$offsp = $_[1];
# check for float
#
# [German:Koresh@OuterSpace] OS would encode it as #-1.00000001e-01# but
# not sure everybody does it this way.
# [German:Fiona] means ({-0.1}) becomes ({#-1.00000001e-01#,}) ?
# [German] Koresh@OuterSpace nods wildly
# [German] Koresh@OuterSpace also notes that mudos does not seem to include
# the # in floats: it just writes it as ({-1.00000e-08,})
#
# LDmud float
# -9.999999997672e-02=fffd:9999999a
pos($str) = $$offsp;
$str =~ m/\G#?(-?\d.\d*[eE][-+]\d\d)(#|=[0-9a-f:]+)?/sg;
if (defined $1) {
$$offsp = pos($str);
return $1;
}
# check for int (check *after* floats)
pos($str) = $$offsp;
$str =~ m/\G(-?\d+)/sg;
if (defined $1) {
$$offsp = pos($str);
return $1;
}
# check for string
pos($str) = $$offsp;
if ($str =~ m/\G"((?:[^"\\]+|\\.)*)"/sg ) {
$$offsp = pos($str);
# unquote string
$ret = $1;
$ret =~ s/\\(.)/$unquote{$1}||$1/esg;
return $ret;
}
# check for array
pos($str) = $$offsp;
if ($str =~ m/\G\({/sg ) {
$$offsp = pos($str);
$data = [];
if ($str =~ m/\G}\)/sg ) {
$$offsp += 2;
return $data;
}
# recurse array
while (1) {
$ret = get_value($str, $offsp);
return -1 if ($parse_err || $offsp == -1);
push @{$data}, $ret;
pos($str) = $$offsp;
if (not ($str =~ m/\G,/sg )) {
pos($str) = $$offsp;
$str =~ m/\G(.{0,8})/sg;
$parse_err = "Comma missing in array near '$1'";
return -1;
}
$$offsp += 1;
if ($str =~ m/\G}\)/sg ) {
$$offsp += 2;
return $data;
}
}
# notreached
}
# check for mapping
#
# MudOS has no 2dimensional Mappings, so we dont support them
# (perl is unable to represent them anyhow)
# Zero-width mappings are impossible with mudmode/perl, so emulate them.
pos($str) = $$offsp;
if ($str =~ m/\G\(\[/sg ) {
$$offsp = pos($str);
$data = {};
if ($str =~ m/\G]\)/sg ) {
$$offsp += 2;
return $data;
}
# recurse array
while (1) {
$ret = get_value($str, $offsp);
return -1 if ($parse_err || $offsp == -1);
pos($str) = $$offsp;
if (not ($str =~ m/\G[:,]/sg )) {
pos($str) = $$offsp;
if ($str =~ m/\G;/sg ) {
$parse_err = 'Multidimensional mapping not supported near ';
} else {
$parse_err = 'Colon missing in mapping near ';
}
pos($str) = $$offsp;
$str =~ m/\G(.{0,8})/sg;
$parse_err = $parse_err . "'$1'";
return -1;
}
$$offsp += 1;
pos($str) = $$offsp-1;
if ($str =~ m/\G,/sg ) { # zero width, gets simulated...
$ret2 = 0;
} else {
$ret2 = get_value($str, $offsp);
return -1 if ($parse_err || $offsp == -1);
pos($str) = $$offsp;
if (not ($str =~ m/\G,/sg )) {
pos($str) = $$offsp;
$str =~ m/\G(.{0,8})/sg;
$parse_err = "Comma missing in mapping near '$1'";
return -1;
}
$$offsp += 1;
}
$$data{$ret} = $ret2;
if ($str =~ m/\G]\)/sg ) {
$$offsp += 2;
return $data;
}
}
# notreached
}
# check for parse error
pos($str) = $$offsp;
$str =~ m/\G(.{1,8})/sg;
if (defined $1) {
$parse_err = "Unknown variable type near '$1'";
return -1;
}
# end of string
$$offsp = -1;
return -1;
}
######
#
# Sample usage
#
$str = '({1234,45,({12,-1,({0,}),}),"fla\nb\"ber",-1.110999999642e+02=7:90e66667,({}),(["b":"a","c":({1,-2,}),]),([1,2,3,]),})';
#$str='({"error",5,"*gjs",0,"Test-PerlMud-i3",0,"unk-src","router does not know you",({"startup-req-3",5,"Test-PerlMud-i3",0,"",0,1016,4156424,330,0,0,0,"PerlLib v1","PerlLib v1","Perlv5.6.1","Perl","restricted access","castaway@desert-island.m.isar.de",(["channel":1,"nntp":0,"file":0,"amcp":0,"rcp":0,"emoteto":1,"auth":0,"who":1,"smtp":0,"mail":0,"finger":1,"ucache":1,"locate":1,"news":0,"http":0,"ftp":0,"tell":1,]),0,}),})';
$posi = 0;
$ret = get_value($str, \$posi);
if ($parse_err) {
print("ERROR $parse_err\n");
} else {
print(Dumper($ret));
}