Function: ebnf-dtd-prolog
ebnf-dtd-prolog is a byte-compiled function defined in ebnf-dtd.el.gz.
Signature
(ebnf-dtd-prolog TOKEN)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ebnf-dtd.el.gz
;;; prolog ::= XMLDecl? Misc* (doctypedecl Misc*)?
;;;
;;; XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
;;;
;;; VersionInfo ::= S 'version' Eq ("'" VersionNum "'" | '"' VersionNum '"')
;;;
;;; Eq ::= S? '=' S?
;;;
;;; VersionNum ::= '1.0'
;;;
;;; Misc ::= Comment | PI | S
;;;
;;; EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'" )
;;;
;;; EncName ::= [A-Za-z] ([-A-Za-z0-9._])*
;;; /* Encoding name contains only Latin characters */
;;;
;;; SDDecl ::= S 'standalone' Eq
;;; (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
;;;
;;; doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
;;; ('[' intSubset ']' S?)? '>'
(defun ebnf-dtd-prolog (token)
(when (and (eq token 'begin-pi) (string= ebnf-dtd-lex "xml"))
;; version = "1.0"
(setq token (ebnf-dtd-attribute (ebnf-dtd-lex) 'version-attr
"^1\\.0$" "XML version"))
;; ( encoding = "encoding name" )?
(setq token (ebnf-dtd-attribute-optional
token 'encoding-attr
"^[A-Za-z][-A-Za-z0-9._]*$" "XML encoding"))
;; ( standalone = ( "yes" | "no" ) )?
(setq token (ebnf-dtd-attribute-optional
token 'standalone-attr
"^yes|no$" "XML standalone"))
(or (eq token 'end-pi)
(error "Missing end of XML processing instruction")))
;; processing instructions
(setq token (ebnf-dtd-pi (ebnf-dtd-lex)))
(cond
;; DOCTYPE
((eq token 'doctype-decl)
(or (eq (ebnf-dtd-lex) 'name)
(error "Document type name is missing"))
(cons (if (eq (ebnf-dtd-externalid) 'begin-subset)
(ebnf-dtd-lex)
'end-prolog)
'end-subset))
((memq token '(element-decl attlist-decl entity-decl notation-decl))
(cons token 'end-of-input))
(t
'(end-prolog . end-subset))
))