123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353 |
- (require 'ebnf-otz)
- (defvar ebnf-dtd-lex nil
- "Value returned by `ebnf-dtd-lex' function.")
- (defun ebnf-dtd-parser (start)
- "DTD parser."
- (let ((total (+ (- ebnf-limit start) 1))
- (bias (1- start))
- (origin (point))
- rule-list token rule the-end)
- (goto-char start)
- (setq token (ebnf-dtd-lex))
- (and (eq token 'end-of-input)
- (error "Empty DTD file"))
- (setq token (ebnf-dtd-prolog token))
- (unless (eq (car token) 'end-prolog)
- (setq the-end (cdr token)
- token (car token))
- (while (not (eq token the-end))
- (ebnf-message-float
- "Parsing...%s%%"
- (/ (* (- (point) bias) 100.0) total))
- (setq token (ebnf-dtd-intsubset token)
- rule (cdr token)
- token (car token))
- (or (null rule)
- (ebnf-add-empty-rule-list rule)
- (setq rule-list (cons rule rule-list))))
- (or (eq the-end 'end-of-input)
- (eq (ebnf-dtd-lex) 'end-decl)
- (error "Missing end of DOCTYPE"))
-
- (ebnf-message-float "Parsing...%s%%" 100.0))
- (goto-char origin)
- rule-list))
- (defun ebnf-dtd-prolog (token)
- (when (and (eq token 'begin-pi) (string= ebnf-dtd-lex "xml"))
-
- (setq token (ebnf-dtd-attribute (ebnf-dtd-lex) 'version-attr
- "^1\\.0$" "XML version"))
-
- (setq token (ebnf-dtd-attribute-optional
- token 'encoding-attr
- "^[A-Za-z][-A-Za-z0-9._]*$" "XML encoding"))
-
- (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")))
-
- (setq token (ebnf-dtd-pi (ebnf-dtd-lex)))
- (cond
-
- ((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))
- ))
- (defun ebnf-dtd-attribute (token attr match attr-name)
- (or (eq token attr)
- (error "%s attribute is missing" attr-name))
- (ebnf-dtd-attribute-optional token attr match attr-name))
- (defun ebnf-dtd-attribute-optional (token attr match attr-name)
- (when (eq token attr)
- (or (and (eq (ebnf-dtd-lex) 'equal)
- (eq (ebnf-dtd-lex) 'string)
- (string-match match ebnf-dtd-lex))
- (error "XML %s attribute is invalid" attr-name))
- (setq token (ebnf-dtd-lex)))
- token)
- (defun ebnf-dtd-externalid (&optional token)
- (let ((must-have token))
- (or token (setq token (ebnf-dtd-lex)))
- (cond ((eq token 'system)
- (ebnf-dtd-systemliteral))
- ((eq token 'public)
- (ebnf-dtd-pubidliteral)
- (ebnf-dtd-systemliteral))
- (must-have
- (error "Missing `SYSTEM' or `PUBLIC' in external id"))
- (t
- token))))
- (defun ebnf-dtd-systemliteral ()
- (or (eq (ebnf-dtd-lex) 'string)
- (error "System identifier is invalid"))
- (ebnf-dtd-lex))
- (defun ebnf-dtd-pubidliteral ()
- (or (and (eq (ebnf-dtd-lex) 'string)
- (string-match "^[-'()+,./:=?;!*#@$_%\n\r a-zA-Z0-9]*$"
- ebnf-dtd-lex))
- (error "Public identifier is invalid")))
- (defun ebnf-dtd-pi (token)
- (while (eq token 'begin-pi)
- (and (string-match "^[xX][mM][lL]$" ebnf-dtd-lex)
- (error "Processing instruction name can not be `XML'"))
- (while (not (eq (ebnf-dtd-lex) 'end-pi)))
- (setq token (ebnf-dtd-lex)))
- token)
- (defun ebnf-dtd-intsubset (token)
-
- (and (eq token 'begin-pi)
- (setq token (ebnf-dtd-pi token)))
- (cond
- ((memq token '(end-subset end-of-input))
- (cons token nil))
- ((eq token 'pe-ref)
- (cons (ebnf-dtd-lex) nil))
- ((eq token 'element-decl)
- (ebnf-dtd-elementdecl))
- ((eq token 'attlist-decl)
- (ebnf-dtd-attlistdecl))
- ((eq token 'entity-decl)
- (ebnf-dtd-entitydecl))
- ((eq token 'notation-decl)
- (ebnf-dtd-notationdecl))
- (t
- (error "Invalid DOCTYPE element"))
- ))
- (defun ebnf-dtd-elementdecl ()
- (let ((action ebnf-action)
- name token body)
- (setq ebnf-action nil)
- (or (eq (ebnf-dtd-lex) 'name)
- (error "Invalid ELEMENT name"))
- (setq name ebnf-dtd-lex
- token (ebnf-dtd-lex)
- body (cond ((memq token '(empty any))
- (let ((term (ebnf-make-terminal ebnf-dtd-lex)))
- (cons (ebnf-dtd-lex) term)))
- ((eq token 'begin-group)
- (setq token (ebnf-dtd-lex))
- (if (eq token 'pcdata)
- (ebnf-dtd-mixed)
- (ebnf-dtd-children token)))
- (t
- (error "Invalid ELEMENT content"))
- ))
- (or (eq (car body) 'end-decl)
- (error "Missing `>' in ELEMENT declaration"))
- (ebnf-eps-add-production name)
- (cons (ebnf-dtd-lex)
- (ebnf-make-production name (cdr body) action))))
- (defun ebnf-dtd-mixed ()
- (let* ((alt (cons (ebnf-make-terminal ebnf-dtd-lex) nil))
- (token (ebnf-dtd-lex))
- (has-alternative (eq token 'alternative)))
- (while (eq token 'alternative)
- (or (eq (ebnf-dtd-lex) 'name)
- (error "Invalid name"))
- (setq alt (cons ebnf-dtd-lex alt)
- token (ebnf-dtd-lex)))
- (or (eq token 'end-group)
- (error "Missing `)'"))
- (and has-alternative
- (or (eq (ebnf-dtd-lex) 'zero-or-more)
- (error "Missing `*'")))
- (ebnf-token-alternative alt (cons (ebnf-dtd-lex) nil))))
- (defun ebnf-dtd-children (token)
- (ebnf-dtd-operators (ebnf-dtd-choice-seq token)))
- (defun ebnf-dtd-choice-seq (token)
- (setq token (ebnf-dtd-cp token))
- (let (elist)
- (cond
-
- ((eq (car token) 'alternative)
- (while (eq (car token) 'alternative)
- (setq elist (cons (cdr token) elist)
- token (ebnf-dtd-cp (ebnf-dtd-lex))))
- (setq elist (ebnf-token-alternative elist token)))
-
- ((eq (car token) 'comma)
- (while (eq (car token) 'comma)
- (setq elist (cons (cdr token) elist)
- token (ebnf-dtd-cp (ebnf-dtd-lex))))
- (setq elist (ebnf-token-sequence (cons (cdr token) elist))))
-
- (t
- (setq elist (cdr token))))
- (or (eq (car token) 'end-group)
- (error "Missing `)' in ELEMENT content"))
- elist))
- (defun ebnf-dtd-cp (token)
- (ebnf-dtd-operators (cond ((eq token 'name)
- (ebnf-make-terminal ebnf-dtd-lex))
- ((eq token 'begin-group)
- (ebnf-dtd-choice-seq (ebnf-dtd-lex)))
- (t
- (error "Invalid element"))
- )))
- (defun ebnf-dtd-operators (elm)
- (let ((token (ebnf-dtd-lex)))
- (cond ((eq token 'optional)
- (cons (ebnf-dtd-lex) (ebnf-token-optional elm)))
- ((eq token 'zero-or-more)
- (cons (ebnf-dtd-lex) (ebnf-make-zero-or-more elm)))
- ((eq token 'one-or-more)
- (cons (ebnf-dtd-lex) (ebnf-make-one-or-more elm)))
- (t
- (cons token elm))
- )))
- (defun ebnf-dtd-attlistdecl ()
- (or (eq (ebnf-dtd-lex) 'name)
- (error "Invalid ATTLIST name"))
- (let (token)
- (while (eq (setq token (ebnf-dtd-lex)) 'name)
-
- (setq token (ebnf-dtd-lex))
- (cond
- ((eq token 'notation)
- (or (eq (ebnf-dtd-lex) 'begin-group)
- (error "Missing `(' in NOTATION type in ATTLIST declaration"))
- (ebnf-dtd-namelist "NOTATION" '(name)))
- ((eq token 'begin-group)
- (ebnf-dtd-namelist "enumeration" '(name name-char)))
- ((memq token
- '(cdata id idref idrefs entity entities nmtoken nmtokens)))
- (t
- (error "Invalid type in ATTLIST declaration")))
-
- (setq token (ebnf-dtd-lex))
- (unless (memq token '(required implied))
- (and (eq token 'fixed)
- (setq token (ebnf-dtd-lex)))
- (or (and (eq token 'string)
- (string-match
- "^\\(&\\([A-Za-z_:][-A-Za-z0-9._:]*\\|#\\(x[0-9a-fA-F]+\\|[0-9]+\\)\\);\\|[^<&]\\)*$"
- ebnf-dtd-lex))
- (error "Invalid default value in ATTLIST declaration"))))
- (or (eq token 'end-decl)
- (error "Missing `>' in end of ATTLIST"))
- (cons (ebnf-dtd-lex) nil)))
- (defun ebnf-dtd-namelist (type name-list)
- (let (token)
- (while (progn
- (or (memq (ebnf-dtd-lex) name-list)
- (error "Invalid name in %s type in ATTLIST declaration" type))
- (eq (setq token (ebnf-dtd-lex)) 'alternative)))
- (or (eq token 'end-group)
- (error "Missing `)' in %s type in ATTLIST declaration" type))))
- (defun ebnf-dtd-entitydecl ()
- (let* ((token (ebnf-dtd-lex))
- (pedecl (eq token 'percent)))
- (and pedecl
- (setq token (ebnf-dtd-lex)))
- (or (eq token 'name)
- (error "Invalid name of ENTITY"))
- (setq token (ebnf-dtd-lex))
- (if (eq token 'string)
- (if (string-match
- "^\\(%[A-Za-z_:][-A-Za-z0-9._:]*;\\|&\\([A-Za-z_:][-A-Za-z0-9._:]*\\|#\\(x[0-9a-fA-F]+\\|[0-9]+\\)\\);\\|[^%&]\\)*$"
- ebnf-dtd-lex)
- (setq token (ebnf-dtd-lex))
- (error "Invalid ENTITY definition"))
- (setq token (ebnf-dtd-externalid token))
- (when (and (not pedecl) (eq token 'ndata))
- (or (eq (ebnf-dtd-lex) 'name)
- (error "Invalid NDATA name"))
- (setq token (ebnf-dtd-lex))))
- (or (eq token 'end-decl)
- (error "Missing `>' in end of ENTITY"))
- (cons (ebnf-dtd-lex) nil)))
- (defun ebnf-dtd-notationdecl ()
- (or (eq (ebnf-dtd-lex) 'name)
- (error "Invalid name NOTATION"))
- (or (eq (ebnf-dtd-externalid-or-publicid) 'end-decl)
- (error "Missing `>' in end of NOTATION"))
- (cons (ebnf-dtd-lex) nil))
- (defun ebnf-dtd-externalid-or-publicid ()
- (let ((token (ebnf-dtd-lex)))
- (cond ((eq token 'system)
- (ebnf-dtd-systemliteral))
- ((eq token 'public)
- (ebnf-dtd-pubidliteral)
- (and (eq (setq token (ebnf-dtd-lex)) 'string)
- (setq token (ebnf-dtd-lex)))
- token)
- (t
- (error "Missing `SYSTEM' or `PUBLIC'")))))
- (defconst ebnf-dtd-token-table (make-vector 256 'error)
- "Vector used to map characters to a lexical token.")
- (defun ebnf-dtd-initialize ()
- "Initialize EBNF token table."
-
- (let ((char ?\060))
-
- (while (< char ?\072)
- (aset ebnf-dtd-token-table char 'name-char)
- (setq char (1+ char)))
-
- (setq char ?\101)
- (while (< char ?\133)
- (aset ebnf-dtd-token-table char 'name)
- (setq char (1+ char)))
-
- (setq char ?\141)
- (while (< char ?\173)
- (aset ebnf-dtd-token-table char 'name)
- (setq char (1+ char)))
-
- (setq char ?\240)
- (while (< char ?\400)
- (aset ebnf-dtd-token-table char 'name)
- (setq char (1+ char)))
-
- (aset ebnf-dtd-token-table ?_ 'name)
- (aset ebnf-dtd-token-table ?: 'name)
- (aset ebnf-dtd-token-table ?. 'name-char)
- (aset ebnf-dtd-token-table ?- 'name-char)
-
- (aset ebnf-dtd-token-table ?\n 'space)
- (aset ebnf-dtd-token-table ?\r 'space)
- (aset ebnf-dtd-token-table ?\t 'space)
- (aset ebnf-dtd-token-table ?\ 'space)
-
- (aset ebnf-dtd-token-table ?= 'equal)
- (aset ebnf-dtd-token-table ?, 'comma)
- (aset ebnf-dtd-token-table ?* 'zero-or-more)
- (aset ebnf-dtd-token-table ?+ 'one-or-more)
- (aset ebnf-dtd-token-table ?| 'alternative)
- (aset ebnf-dtd-token-table ?% 'percent)
- (aset ebnf-dtd-token-table ?& 'ampersand)
- (aset ebnf-dtd-token-table ?# 'hash)
- (aset ebnf-dtd-token-table ?\? 'interrogation)
- (aset ebnf-dtd-token-table ?\" 'double-quote)
- (aset ebnf-dtd-token-table ?\' 'single-quote)
- (aset ebnf-dtd-token-table ?< 'less-than)
- (aset ebnf-dtd-token-table ?> 'end-decl)
- (aset ebnf-dtd-token-table ?\( 'begin-group)
- (aset ebnf-dtd-token-table ?\) 'end-group)
- (aset ebnf-dtd-token-table ?\[ 'begin-subset)
- (aset ebnf-dtd-token-table ?\] 'end-subset)))
- ;; replace the range "\240-\377" (see `ebnf-range-regexp').
- (defconst ebnf-dtd-name-chars
- (ebnf-range-regexp "-._:0-9A-Za-z" ?\240 ?\377))
- (defconst ebnf-dtd-decl-alist
- '(("ATTLIST" . attlist-decl)
- ("DOCTYPE" . doctype-decl)
- ("ELEMENT" . element-decl)
- ("ENTITY" . entity-decl)
- ("NOTATION" . notation-decl)))
- (defconst ebnf-dtd-element-alist
- '(("#FIXED" . fixed)
- ("#IMPLIED" . implied)
- ("#PCDATA" . pcdata)
- ("#REQUIRED" . required)))
- (defconst ebnf-dtd-name-alist
- '(("ANY" . any)
- ("CDATA" . cdata)
- ("EMPTY" . empty)
- ("ENTITIES" . entities)
- ("ENTITY" . entity)
- ("ID" . id)
- ("IDREF" . idref)
- ("IDREFS" . idrefs)
- ("NDATA" . ndata)
- ("NMTOKEN" . nmtoken)
- ("NMTOKENS" . nmtokens)
- ("NOTATION" . notation)
- ("PUBLIC" . public)
- ("SYSTEM" . system)
- ("encoding" . encoding-attr)
- ("standalone" . standalone-attr)
- ("version" . version-attr)))
- (defun ebnf-dtd-lex ()
- "Lexical analyzer for DTD.
- Return a lexical token.
- See documentation for variable `ebnf-dtd-lex'."
- (if (>= (point) ebnf-limit)
- 'end-of-input
- (let (token)
- ;; skip spaces and comments
- (while (if (> (following-char) 255)
- (progn
- (setq token 'error)
- nil)
- (setq token (aref ebnf-dtd-token-table (following-char)))
- (cond
- ((eq token 'space)
- (skip-chars-forward " \n\r\t" ebnf-limit)
- (< (point) ebnf-limit))
- ((and (eq token 'less-than)
- (looking-at "<!--"))
- (ebnf-dtd-skip-comment))
- (t nil)
- )))
- (cond
- ;; end of input
- ((>= (point) ebnf-limit)
- 'end-of-input)
- ;; error
- ((eq token 'error)
- (error "Invalid character"))
- ;; beginning of declaration:
- ;; <?name, <!ATTLIST, <!DOCTYPE, <!ELEMENT, <!ENTITY, <!NOTATION
- ((eq token 'less-than)
- (forward-char)
- (let ((char (following-char)))
- (cond ((= char ?\?) ; <?
- (forward-char)
- (setq ebnf-dtd-lex (ebnf-buffer-substring ebnf-dtd-name-chars))
- 'begin-pi)
- ((= char ?!) ; <!
- (forward-char)
- (let ((decl (ebnf-buffer-substring ebnf-dtd-name-chars)))
- (or (cdr (assoc decl ebnf-dtd-decl-alist))
- (error "Invalid declaration name `%s'" decl))))
- (t ; <x
- (error "Invalid declaration `<%c'" char)))))
- ;; name, namechar
- ((memq token '(name name-char))
- (setq ebnf-dtd-lex (ebnf-buffer-substring ebnf-dtd-name-chars))
- (or (cdr (assoc ebnf-dtd-lex ebnf-dtd-name-alist))
- token))
- ;; ?, ?>
- ((eq token 'interrogation)
- (forward-char)
- (if (/= (following-char) ?>)
- 'optional
- (forward-char)
- 'end-pi))
- ;; #FIXED, #IMPLIED, #PCDATA, #REQUIRED
- ((eq token 'hash)
- (forward-char)
- (setq ebnf-dtd-lex
- (concat "#" (ebnf-buffer-substring ebnf-dtd-name-chars)))
- (or (cdr (assoc ebnf-dtd-lex ebnf-dtd-element-alist))
- (error "Invalid element `%s'" ebnf-dtd-lex)))
- ;; "string"
- ((eq token 'double-quote)
- (setq ebnf-dtd-lex (ebnf-dtd-string ?\"))
- 'string)
- ;; 'string'
- ((eq token 'single-quote)
- (setq ebnf-dtd-lex (ebnf-dtd-string ?\'))
- 'string)
- ;; %, %name;
- ((eq token 'percent)
- (forward-char)
- (if (looking-at "[ \n\r\t]")
- 'percent
- (setq ebnf-dtd-lex (ebnf-dtd-name-ref "%"))
- 'pe-ref))
- ;; &#...;, &#x...;, &name;
- ((eq token 'ampersand)
- (forward-char)
- (if (/= (following-char) ?#)
- (progn
- ;; &name;
- (setq ebnf-dtd-lex (ebnf-dtd-name-ref "&"))
- 'entity-ref)
- ;; &#...;, &#x...;
- (forward-char)
- (setq ebnf-dtd-lex (if (/= (following-char) ?x)
- (ebnf-dtd-char-ref "&#" "0-9")
- (forward-char)
- (ebnf-dtd-char-ref "&#x" "0-9a-fA-F")))
- 'char-ref))
- ;; miscellaneous: (, ), [, ], =, |, *, +, >, `,'
- (t
- (forward-char)
- token)
- ))))
- (defun ebnf-dtd-name-ref (start)
- (ebnf-dtd-char-ref start ebnf-dtd-name-chars))
- (defun ebnf-dtd-char-ref (start chars)
- (let ((char (ebnf-buffer-substring chars)))
- (or (= (following-char) ?\;)
- (error "Invalid element `%s%s%c'" start char (following-char)))
- (forward-char)
- (format "%s%s;" start char)))
- ;; replace the range "\240-\377" (see `ebnf-range-regexp').
- (defconst ebnf-dtd-double-string-chars
- (ebnf-range-regexp "\t -!#-~" ?\240 ?\377))
- (defconst ebnf-dtd-single-string-chars
- (ebnf-range-regexp "\t -&(-~" ?\240 ?\377))
- (defun ebnf-dtd-string (delim)
- (buffer-substring-no-properties
- (progn
- (forward-char)
- (point))
- (progn
- (skip-chars-forward (if (= delim ?\")
- ebnf-dtd-double-string-chars
- ebnf-dtd-single-string-chars)
- ebnf-limit)
- (or (= (following-char) delim)
- (error "Missing string delimiter `%c'" delim))
- (prog1
- (point)
- (forward-char)))))
- ;; replace the range "\177-\237" (see `ebnf-range-regexp').
- (defconst ebnf-dtd-comment-chars
- (ebnf-range-regexp "\000-\010\013\014\016-\037" ?\177 ?\237))
- (defconst ebnf-dtd-filename-chars
- (ebnf-range-regexp "\000-\037" ?\177 ?\237))
- (defun ebnf-dtd-skip-comment ()
- (forward-char 4) ; <!--
- (cond
- ;; open EPS file
- ((and ebnf-eps-executing (= (following-char) ?\[))
- (ebnf-eps-add-context (ebnf-dtd-eps-filename)))
- ;; close EPS file
- ((and ebnf-eps-executing (= (following-char) ?\]))
- (ebnf-eps-remove-context (ebnf-dtd-eps-filename)))
- ;; EPS header
- ((and ebnf-eps-executing (= (following-char) ?H))
- (ebnf-eps-header-comment (ebnf-dtd-eps-filename)))
- ;; EPS footer
- ((and ebnf-eps-executing (= (following-char) ?F))
- (ebnf-eps-footer-comment (ebnf-dtd-eps-filename)))
- ;; any other action in comment
- (t
- (setq ebnf-action (aref ebnf-comment-table (following-char))))
- )
- (while (progn
- (skip-chars-forward ebnf-dtd-comment-chars ebnf-limit)
- (and (< (point) ebnf-limit)
- (not (looking-at "-->"))))
- (skip-chars-forward "-" ebnf-limit))
- ;; check for a valid end of comment
- (cond ((>= (point) ebnf-limit)
- nil)
- ((looking-at "-->")
- (forward-char 3)
- t)
- (t
- (error "Invalid character"))
- ))
- (defun ebnf-dtd-eps-filename ()
- (forward-char)
- (let (fname)
- (while (progn
- (setq fname
- (concat fname
- (ebnf-buffer-substring ebnf-dtd-filename-chars)))
- (and (< (point) ebnf-limit)
- (= (following-char) ?-) ; may be \n, \t, \r
- (not (looking-at "-->"))))
- (setq fname (concat fname (ebnf-buffer-substring "-"))))
- fname))
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (provide 'ebnf-dtd)
- ;;; ebnf-dtd.el ends here
|