Report a syntax error on "(?<".
Instead of failing due to NIL not being a character in a call to ALPHA-CHAR-P.
This commit is contained in:
62
lexer.lisp
62
lexer.lisp
@ -672,37 +672,39 @@ closing #\> will also be consumed."
|
|||||||
;; might be a look-behind assertion or a named group, so
|
;; might be a look-behind assertion or a named group, so
|
||||||
;; check next character
|
;; check next character
|
||||||
(let ((next-char (next-char-non-extended lexer)))
|
(let ((next-char (next-char-non-extended lexer)))
|
||||||
(if (alpha-char-p next-char)
|
(cond ((and next-char
|
||||||
(progn
|
(alpha-char-p next-char))
|
||||||
;; we have encountered a named group
|
;; we have encountered a named group
|
||||||
;; are we supporting register naming?
|
;; are we supporting register naming?
|
||||||
(unless *allow-named-registers*
|
(unless *allow-named-registers*
|
||||||
(signal-syntax-error* (1- (lexer-pos lexer))
|
(signal-syntax-error* (1- (lexer-pos lexer))
|
||||||
"Character '~A' may not follow '(?<'."
|
"Character '~A' may not follow '(?<' (because ~a = NIL)"
|
||||||
next-char))
|
next-char
|
||||||
;; put the letter back
|
'*allow-named-registers*))
|
||||||
(decf (lexer-pos lexer))
|
;; put the letter back
|
||||||
;; named group
|
(decf (lexer-pos lexer))
|
||||||
:open-paren-less-letter)
|
;; named group
|
||||||
(case next-char
|
:open-paren-less-letter)
|
||||||
((#\=)
|
|
||||||
;; positive look-behind
|
|
||||||
:open-paren-less-equal)
|
|
||||||
((#\!)
|
|
||||||
;; negative look-behind
|
|
||||||
:open-paren-less-exclamation)
|
|
||||||
((#\))
|
|
||||||
;; Perl allows "(?<)" and treats
|
|
||||||
;; it like a null string
|
|
||||||
:void)
|
|
||||||
((nil)
|
|
||||||
;; syntax error
|
|
||||||
(signal-syntax-error "End of string following '(?<'."))
|
|
||||||
(t
|
(t
|
||||||
;; also syntax error
|
(case next-char
|
||||||
(signal-syntax-error* (1- (lexer-pos lexer))
|
((#\=)
|
||||||
"Character '~A' may not follow '(?<'."
|
;; positive look-behind
|
||||||
next-char ))))))
|
:open-paren-less-equal)
|
||||||
|
((#\!)
|
||||||
|
;; negative look-behind
|
||||||
|
:open-paren-less-exclamation)
|
||||||
|
((#\))
|
||||||
|
;; Perl allows "(?<)" and treats
|
||||||
|
;; it like a null string
|
||||||
|
:void)
|
||||||
|
((nil)
|
||||||
|
;; syntax error
|
||||||
|
(signal-syntax-error "End of string following '(?<'."))
|
||||||
|
(t
|
||||||
|
;; also syntax error
|
||||||
|
(signal-syntax-error* (1- (lexer-pos lexer))
|
||||||
|
"Character '~A' may not follow '(?<'."
|
||||||
|
next-char )))))))
|
||||||
(otherwise
|
(otherwise
|
||||||
(signal-syntax-error* (1- (lexer-pos lexer))
|
(signal-syntax-error* (1- (lexer-pos lexer))
|
||||||
"Character '~A' may not follow '(?'."
|
"Character '~A' may not follow '(?'."
|
||||||
|
|||||||
Reference in New Issue
Block a user