Function: ebnf-iso-lex
ebnf-iso-lex is a byte-compiled function defined in ebnf-iso.el.gz.
Signature
(ebnf-iso-lex)
Documentation
Lexical analyzer for ISO EBNF.
Return a lexical token.
See documentation for variable ebnf-iso-lex(var)/ebnf-iso-lex(fun).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ebnf-iso.el.gz
(defun ebnf-iso-lex ()
"Lexical analyzer for ISO EBNF.
Return a lexical token.
See documentation for variable `ebnf-iso-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-iso-token-table (following-char)))
(cond
((eq token 'space)
(skip-chars-forward " \013\n\r\t" ebnf-limit)
(< (point) ebnf-limit))
((or (eq token 'begin-parenthesis)
(eq token 'left-parenthesis))
(forward-char)
(if (/= (following-char) ?*)
;; no comment
nil
;; comment
(ebnf-iso-skip-comment)
t))
((eq token 'form-feed)
(forward-char)
(setq ebnf-action 'form-feed))
(t nil)
)))
(cond
;; end of input
((>= (point) ebnf-limit)
'end-of-input)
;; error
((eq token 'error)
(error "Invalid character"))
;; integer
((eq token 'integer)
(setq ebnf-iso-lex (ebnf-buffer-substring "0-9"))
'integer)
;; special: ?special?
((eq token 'special)
(setq ebnf-iso-lex (concat (and ebnf-special-show-delimiter "?")
(ebnf-string " ->@-~" ?\? "special")
(and ebnf-special-show-delimiter "?")))
'special)
;; terminal: "string"
((eq token 'double-terminal)
(setq ebnf-iso-lex (ebnf-string " !#-~" ?\" "terminal"))
'terminal)
;; terminal: 'string'
((eq token 'single-terminal)
(setq ebnf-iso-lex (ebnf-string " -&(-~" ?\' "terminal"))
'terminal)
;; non-terminal
((eq token 'non-terminal)
(setq ebnf-iso-lex
(ebnf-iso-normalize
(ebnf-trim-right
(ebnf-buffer-substring ebnf-iso-non-terminal-chars))))
(and ebnf-no-meta-identifier
(error "Exception sequence should not contain a meta identifier"))
'non-terminal)
;; begin optional, begin list or begin group
((eq token 'left-parenthesis)
(forward-char)
(cond ((= (following-char) ?/)
(forward-char)
'begin-optional)
((= (following-char) ?:)
(forward-char)
'begin-zero-or-more)
(t
'begin-group)
))
;; end optional or alternative
((eq token 'slash)
(forward-char)
(if (/= (following-char) ?\))
'alternative
(forward-char)
'end-optional))
;; end list
((eq token 'colon)
(forward-char)
(if (/= (following-char) ?\))
'character
(forward-char)
'end-zero-or-more))
;; begin group
((eq token 'begin-parenthesis)
'begin-group)
;; miscellaneous
(t
(forward-char)
token)
))))