regexp: fix take-until to handle escapes at the end of a regexp.

this worked:
R\ //.\

this didn't:
R\ //\
windows-drag
John Benediktsson 2019-03-17 09:52:53 -07:00
parent a3d5e3ffcb
commit 2136abc1d6
1 changed files with 5 additions and 4 deletions

View File

@ -200,10 +200,11 @@ PRIVATE>
: take-until ( lexer -- string ) : take-until ( lexer -- string )
dup skip-blank [ dup skip-blank [
dupd [ dupd [
[ CHAR: / -rot index-from ] keep [ [ "\\/" member? ] find-from ] keep swap [
over [ "Unterminated regexp" throw ] unless CHAR: \ = [ [ 2 + ] dip t ] [ f ] if
2dup [ 1 - ] dip nth CHAR: \\ = ] [
[ [ [ 1 + ] dip ] when ] keep "Unterminated regexp" throw
] if*
] loop over [ subseq ] dip 1 + ] loop over [ subseq ] dip 1 +
] change-lexer-column ; ] change-lexer-column ;