Function: ebnf-abn-lex
ebnf-abn-lex is a byte-compiled function defined in ebnf-abn.el.gz.
Signature
(ebnf-abn-lex)
Documentation
Lexical analyzer for ABNF.
Return a lexical token.
See documentation for variable ebnf-abn-lex(var)/ebnf-abn-lex(fun).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ebnf-abn.el.gz
(defun ebnf-abn-lex ()
"Lexical analyzer for ABNF.
Return a lexical token.
See documentation for variable `ebnf-abn-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-abn-token-table (following-char)))
(cond
((eq token 'space)
(skip-chars-forward " \013\t" ebnf-limit)
(< (point) ebnf-limit))
((eq token 'comment)
(ebnf-abn-skip-comment))
((eq token 'form-feed)
(forward-char)
(setq ebnf-action 'form-feed))
((eq token 'end-of-rule)
(ebnf-abn-skip-end-of-rule))
(t nil)
)))
(cond
;; end of input
((>= (point) ebnf-limit)
'end-of-input)
;; error
((eq token 'error)
(error "Invalid character"))
;; end of rule
((eq token 'end-of-rule)
'end-of-rule)
;; integer
((eq token 'integer)
(setq ebnf-abn-lex (ebnf-buffer-substring "0-9"))
'integer)
;; terminal: "string" or %[bdx]NNN((.NNN)+|-NNN)?
((eq token 'terminal)
(setq ebnf-abn-lex
(if (= (following-char) ?\")
(ebnf-abn-string)
(ebnf-abn-character)))
'terminal)
;; non-terminal: NAME or <NAME>
((eq token 'non-terminal)
(let ((prose-p (= (following-char) ?<)))
(when prose-p
(forward-char)
(or (looking-at (concat "[" ebnf-abn-non-terminal-letter-chars "]"))
(error "Invalid prose value")))
(setq ebnf-abn-lex
(ebnf-buffer-substring ebnf-abn-non-terminal-chars))
(when prose-p
(or (= (following-char) ?>)
(error "Invalid prose value"))
(forward-char)
(setq ebnf-abn-lex (concat "<" ebnf-abn-lex ">"))))
'non-terminal)
;; equal: =, =/
((eq token 'equal)
(forward-char)
(if (/= (following-char) ?/)
'equal
(forward-char)
'incremental-alternative))
;; miscellaneous: (, ), [, ], /, *
(t
(forward-char)
token)
))))