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