• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/emacs-93/emacs/lisp/progmodes/

Lines Matching +defs:ebnf +defs:dtd +defs:initialize

0 ;;; ebnf-dtd.el --- parser for DTD (Data Type Description for XML)
8 ;; Keywords: wp, ebnf, PostScript
523 ;; Besides the syntax above, ebnf-dtd also accepts a `pure' dtd file. An
524 ;; example of a `pure' dtd file is:
550 (require 'ebnf-otz)
553 (defvar ebnf-dtd-lex nil
554 "Value returned by `ebnf-dtd-lex' function.")
565 (defun ebnf-dtd-parser (start)
567 (let ((total (+ (- ebnf-limit start) 1))
572 (setq token (ebnf-dtd-lex))
575 (setq token (ebnf-dtd-prolog token))
580 (ebnf-message-float
583 (setq token (ebnf-dtd-intsubset token)
587 (ebnf-add-empty-rule-list rule)
590 (eq (ebnf-dtd-lex) 'end-decl)
593 (ebnf-message-float "Parsing...%s%%" 100.0))
622 (defun ebnf-dtd-prolog (token)
623 (when (and (eq token 'begin-pi) (string= ebnf-dtd-lex "xml"))
625 (setq token (ebnf-dtd-attribute (ebnf-dtd-lex) 'version-attr
628 (setq token (ebnf-dtd-attribute-optional
632 (setq token (ebnf-dtd-attribute-optional
638 (setq token (ebnf-dtd-pi (ebnf-dtd-lex)))
642 (or (eq (ebnf-dtd-lex) 'name)
644 (cons (if (eq (ebnf-dtd-externalid) 'begin-subset)
645 (ebnf-dtd-lex)
655 (defun ebnf-dtd-attribute (token attr match attr-name)
658 (ebnf-dtd-attribute-optional token attr match attr-name))
661 (defun ebnf-dtd-attribute-optional (token attr match attr-name)
663 (or (and (eq (ebnf-dtd-lex) 'equal)
664 (eq (ebnf-dtd-lex) 'string)
665 (string-match match ebnf-dtd-lex))
667 (setq token (ebnf-dtd-lex)))
675 (defun ebnf-dtd-externalid (&optional token)
677 (or token (setq token (ebnf-dtd-lex)))
679 (ebnf-dtd-systemliteral))
681 (ebnf-dtd-pubidliteral)
682 (ebnf-dtd-systemliteral))
693 (defun ebnf-dtd-systemliteral ()
694 (or (eq (ebnf-dtd-lex) 'string)
696 (ebnf-dtd-lex))
705 (defun ebnf-dtd-pubidliteral ()
706 (or (and (eq (ebnf-dtd-lex) 'string)
708 ebnf-dtd-lex))
717 (defun ebnf-dtd-pi (token)
719 (and (string-match "^[xX][mM][lL]$" ebnf-dtd-lex)
721 (while (not (eq (ebnf-dtd-lex) 'end-pi)))
722 (setq token (ebnf-dtd-lex)))
737 (defun ebnf-dtd-intsubset (token)
740 (setq token (ebnf-dtd-pi token)))
745 (cons (ebnf-dtd-lex) nil)) ; annotation
747 (ebnf-dtd-elementdecl)) ; rule
749 (ebnf-dtd-attlistdecl)) ; annotation
751 (ebnf-dtd-entitydecl)) ; annotation
753 (ebnf-dtd-notationdecl)) ; annotation
775 (defun ebnf-dtd-elementdecl ()
776 (let ((action ebnf-action)
778 (setq ebnf-action nil)
779 (or (eq (ebnf-dtd-lex) 'name)
781 (setq name ebnf-dtd-lex
782 token (ebnf-dtd-lex)
784 (let ((term (ebnf-make-terminal ebnf-dtd-lex)))
785 (cons (ebnf-dtd-lex) term)))
787 (setq token (ebnf-dtd-lex))
789 (ebnf-dtd-mixed)
790 (ebnf-dtd-children token)))
796 (ebnf-eps-add-production name)
797 (cons (ebnf-dtd-lex)
798 (ebnf-make-production name (cdr body) action))))
805 (defun ebnf-dtd-mixed ()
806 (let* ((alt (cons (ebnf-make-terminal ebnf-dtd-lex) nil))
807 (token (ebnf-dtd-lex))
810 (or (eq (ebnf-dtd-lex) 'name)
812 (setq alt (cons ebnf-dtd-lex alt)
813 token (ebnf-dtd-lex)))
817 (or (eq (ebnf-dtd-lex) 'zero-or-more)
819 (ebnf-token-alternative alt (cons (ebnf-dtd-lex) nil))))
825 (defun ebnf-dtd-children (token)
826 (ebnf-dtd-operators (ebnf-dtd-choice-seq token)))
834 (defun ebnf-dtd-choice-seq (token)
835 (setq token (ebnf-dtd-cp token))
842 token (ebnf-dtd-cp (ebnf-dtd-lex))))
843 (setq elist (ebnf-token-alternative elist token)))
848 token (ebnf-dtd-cp (ebnf-dtd-lex))))
849 (setq elist (ebnf-token-sequence (cons (cdr token) elist))))
861 (defun ebnf-dtd-cp (token)
862 (ebnf-dtd-operators (cond ((eq token 'name)
863 (ebnf-make-terminal ebnf-dtd-lex))
865 (ebnf-dtd-choice-seq (ebnf-dtd-lex)))
874 (defun ebnf-dtd-operators (elm)
875 (let ((token (ebnf-dtd-lex)))
877 (cons (ebnf-dtd-lex) (ebnf-token-optional elm)))
879 (cons (ebnf-dtd-lex) (ebnf-make-zero-or-more elm)))
881 (cons (ebnf-dtd-lex) (ebnf-make-one-or-more elm)))
927 (defun ebnf-dtd-attlistdecl ()
928 (or (eq (ebnf-dtd-lex) 'name)
931 (while (eq (setq token (ebnf-dtd-lex)) 'name)
933 (setq token (ebnf-dtd-lex))
936 (or (eq (ebnf-dtd-lex) 'begin-group)
938 (ebnf-dtd-namelist "NOTATION" '(name)))
940 (ebnf-dtd-namelist "enumeration" '(name name-char)))
946 (setq token (ebnf-dtd-lex))
949 (setq token (ebnf-dtd-lex)))
953 ebnf-dtd-lex))
957 (cons (ebnf-dtd-lex) nil)))
960 (defun ebnf-dtd-namelist (type name-list)
963 (or (memq (ebnf-dtd-lex) name-list)
965 (eq (setq token (ebnf-dtd-lex)) 'alternative)))
998 (defun ebnf-dtd-entitydecl ()
999 (let* ((token (ebnf-dtd-lex))
1002 (setq token (ebnf-dtd-lex)))
1005 (setq token (ebnf-dtd-lex))
1009 ebnf-dtd-lex)
1010 (setq token (ebnf-dtd-lex))
1012 (setq token (ebnf-dtd-externalid token))
1014 (or (eq (ebnf-dtd-lex) 'name)
1016 (setq token (ebnf-dtd-lex))))
1019 (cons (ebnf-dtd-lex) nil)))
1027 (defun ebnf-dtd-notationdecl ()
1028 (or (eq (ebnf-dtd-lex) 'name)
1030 (or (eq (ebnf-dtd-externalid-or-publicid) 'end-decl)
1032 (cons (ebnf-dtd-lex) nil))
1041 (defun ebnf-dtd-externalid-or-publicid ()
1042 (let ((token (ebnf-dtd-lex)))
1044 (ebnf-dtd-systemliteral))
1046 (ebnf-dtd-pubidliteral)
1047 (and (eq (setq token (ebnf-dtd-lex)) 'string)
1048 (setq token (ebnf-dtd-lex)))
1059 (defconst ebnf-dtd-token-table (make-vector 256 'error)
1063 (defun ebnf-dtd-initialize ()
1069 (aset ebnf-dtd-token-table char 'name-char)
1074 (aset ebnf-dtd-token-table char 'name)
1079 (aset ebnf-dtd-token-table char 'name)
1084 (aset ebnf-dtd-token-table char 'name)
1087 (aset ebnf-dtd-token-table ?_ 'name)
1088 (aset ebnf-dtd-token-table ?: 'name)
1089 (aset ebnf-dtd-token-table ?. 'name-char)
1090 (aset ebnf-dtd-token-table ?- 'name-char)
1092 (aset ebnf-dtd-token-table ?\n 'space) ; [NL] linefeed
1093 (aset ebnf-dtd-token-table ?\r 'space) ; [CR] carriage return
1094 (aset ebnf-dtd-token-table ?\t 'space) ; [HT] horizontal tab
1095 (aset ebnf-dtd-token-table ?\ 'space) ; [SP] space
1097 (aset ebnf-dtd-token-table ?= 'equal)
1098 (aset ebnf-dtd-token-table ?, 'comma)
1099 (aset ebnf-dtd-token-table ?* 'zero-or-more)
1100 (aset ebnf-dtd-token-table ?+ 'one-or-more)
1101 (aset ebnf-dtd-token-table ?| 'alternative)
1102 (aset ebnf-dtd-token-table ?% 'percent)
1103 (aset ebnf-dtd-token-table ?& 'ampersand)
1104 (aset ebnf-dtd-token-table ?# 'hash)
1105 (aset ebnf-dtd-token-table ?\? 'interrogation)
1106 (aset ebnf-dtd-token-table ?\" 'double-quote)
1107 (aset ebnf-dtd-token-table ?\' 'single-quote)
1108 (aset ebnf-dtd-token-table ?< 'less-than)
1109 (aset ebnf-dtd-token-table ?> 'end-decl)
1110 (aset ebnf-dtd-token-table ?\( 'begin-group)
1111 (aset ebnf-dtd-token-table ?\) 'end-group)
1112 (aset ebnf-dtd-token-table ?\[ 'begin-subset)
1113 (aset ebnf-dtd-token-table ?\] 'end-subset)))
1116 ;; replace the range "\240-\377" (see `ebnf-range-regexp').
1117 (defconst ebnf-dtd-name-chars
1118 (ebnf-range-regexp "-._:0-9A-Za-z" ?\240 ?\377))
1121 (defconst ebnf-dtd-decl-alist
1129 (defconst ebnf-dtd-element-alist
1136 (defconst ebnf-dtd-name-alist
1156 (defun ebnf-dtd-lex ()
1161 See documentation for variable `ebnf-dtd-lex'."
1162 (if (>= (point) ebnf-limit)
1170 (setq token (aref ebnf-dtd-token-table (following-char)))
1173 (skip-chars-forward " \n\r\t" ebnf-limit)
1174 (< (point) ebnf-limit))
1177 (ebnf-dtd-skip-comment))
1182 ((>= (point) ebnf-limit)
1194 (setq ebnf-dtd-lex (ebnf-buffer-substring ebnf-dtd-name-chars))
1198 (let ((decl (ebnf-buffer-substring ebnf-dtd-name-chars)))
1199 (or (cdr (assoc decl ebnf-dtd-decl-alist))
1205 (setq ebnf-dtd-lex (ebnf-buffer-substring ebnf-dtd-name-chars))
1206 (or (cdr (assoc ebnf-dtd-lex ebnf-dtd-name-alist))
1218 (setq ebnf-dtd-lex
1219 (concat "#" (ebnf-buffer-substring ebnf-dtd-name-chars)))
1220 (or (cdr (assoc ebnf-dtd-lex ebnf-dtd-element-alist))
1221 (error "Invalid element `%s'" ebnf-dtd-lex)))
1224 (setq ebnf-dtd-lex (ebnf-dtd-string ?\"))
1228 (setq ebnf-dtd-lex (ebnf-dtd-string ?\'))
1235 (setq ebnf-dtd-lex (ebnf-dtd-name-ref "%"))
1243 (setq ebnf-dtd-lex (ebnf-dtd-name-ref "&"))
1247 (setq ebnf-dtd-lex (if (/= (following-char) ?x)
1248 (ebnf-dtd-char-ref "&#" "0-9")
1250 (ebnf-dtd-char-ref "&#x" "0-9a-fA-F")))
1259 (defun ebnf-dtd-name-ref (start)
1260 (ebnf-dtd-char-ref start ebnf-dtd-name-chars))
1263 (defun ebnf-dtd-char-ref (start chars)
1264 (let ((char (ebnf-buffer-substring chars)))
1271 ;; replace the range "\240-\377" (see `ebnf-range-regexp').
1272 (defconst ebnf-dtd-double-string-chars
1273 (ebnf-range-regexp "\t -!#-~" ?\240 ?\377))
1274 (defconst ebnf-dtd-single-string-chars
1275 (ebnf-range-regexp "\t -&(-~" ?\240 ?\377))
1278 (defun ebnf-dtd-string (delim)
1285 ebnf-dtd-double-string-chars
1286 ebnf-dtd-single-string-chars)
1287 ebnf-limit)
1295 ;; replace the range "\177-\237" (see `ebnf-range-regexp').
1296 (defconst ebnf-dtd-comment-chars
1297 (ebnf-range-regexp "^-\000-\010\013\014\016-\037" ?\177 ?\237))
1298 (defconst ebnf-dtd-filename-chars
1299 (ebnf-range-regexp "^-\000-\037" ?\177 ?\237))
1302 (defun ebnf-dtd-skip-comment ()
1306 ((and ebnf-eps-executing (= (following-char) ?\[))
1307 (ebnf-eps-add-context (ebnf-dtd-eps-filename)))
1309 ((and ebnf-eps-executing (= (following-char) ?\]))
1310 (ebnf-eps-remove-context (ebnf-dtd-eps-filename)))
1313 (setq ebnf-action (aref ebnf-comment-table (following-char))))
1316 (skip-chars-forward ebnf-dtd-comment-chars ebnf-limit)
1317 (and (< (point) ebnf-limit)
1319 (skip-chars-forward "-" ebnf-limit))
1321 (cond ((>= (point) ebnf-limit)
1331 (defun ebnf-dtd-eps-filename ()
1337 (ebnf-buffer-substring ebnf-dtd-filename-chars)))
1338 (and (< (point) ebnf-limit)
1341 (setq fname (concat fname (ebnf-buffer-substring "-"))))
1349 (provide 'ebnf-dtd)
1352 ;;; ebnf-dtd.el ends here