use sequences.deep's flatten
parent
2f48327b47
commit
a969b9c778
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: lazy-lists promises kernel sequences strings math
|
USING: lazy-lists promises kernel sequences strings math
|
||||||
arrays splitting quotations combinators namespaces
|
arrays splitting quotations combinators namespaces
|
||||||
unicode.case unicode.categories ;
|
unicode.case unicode.categories sequences.deep ;
|
||||||
IN: parser-combinators
|
IN: parser-combinators
|
||||||
|
|
||||||
! Parser combinator protocol
|
! Parser combinator protocol
|
||||||
|
@ -329,11 +329,6 @@ LAZY: <(+)> ( parser -- parser )
|
||||||
LAZY: surrounded-by ( parser start end -- parser' )
|
LAZY: surrounded-by ( parser start end -- parser' )
|
||||||
[ token ] 2apply swapd pack ;
|
[ token ] 2apply swapd pack ;
|
||||||
|
|
||||||
: flatten* ( obj -- )
|
|
||||||
dup array? [ [ flatten* ] each ] [ , ] if ;
|
|
||||||
|
|
||||||
: flatten [ flatten* ] { } make ;
|
|
||||||
|
|
||||||
: exactly-n ( parser n -- parser' )
|
: exactly-n ( parser n -- parser' )
|
||||||
swap <repetition> <and-parser> [ flatten ] <@ ;
|
swap <repetition> <and-parser> [ flatten ] <@ ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue