peg.parsers: simplify range-pattern.

clean-linux-x86-32
John Benediktsson 2019-09-25 21:34:28 -07:00
parent 689c18c374
commit 0150e4c303
1 changed files with 4 additions and 5 deletions

View File

@ -91,8 +91,7 @@ PRIVATE>
any-char ,
] seq* [
first2 [a,b] >string
] action
replace ;
] action replace ;
: range-pattern ( pattern -- parser )
! 'pattern' is a set of characters describing the
@ -103,8 +102,8 @@ PRIVATE>
! characters separated with a dash (-) represents the
! range of characters from the first to the second,
! inclusive.
dup first CHAR: ^ = [
rest (range-pattern) [ member? not ] curry satisfy
"^" ?head [
(range-pattern) '[ _ member? not ] satisfy
] [
(range-pattern) [ member? ] curry satisfy
(range-pattern) '[ _ member? ] satisfy
] if ;