     #! A parser that always fails and returns
     #! an empty list of successes.
     2drop nil ;
+
+TUPLE: ensure-parser test ;
+
+: ensure ( parser -- ensure )
+    ensure-parser construct-boa ;
+
+M: ensure-parser parse ( input parser -- list )
+    2dup ensure-parser-test parse nil?
+    [ 2drop nil ] [ drop t swap <parse-results> ] if ;
+
+TUPLE: ensure-not-parser test ;
+
+: ensure-not ( parser -- ensure )
+    ensure-not-parser construct-boa ;
+
+M: ensure-not-parser parse ( input parser -- list )
+    2dup ensure-not-parser-test parse nil?
+    [ drop t swap <parse-results> ] [ 2drop nil ] if ;
 
 TUPLE: and-parser parsers ;
 

M: succeed-parser parse ( input parser -- list )
    #! A parser that always returns 'result' as a
    #! successful parse with no input consumed.
    succeed-parser-result swap <parse-result> 1list ;

TUPLE: fail-parser ;


M: token-parser parse ( input parser -- list )
    dup token-parser-string swap token-parser-ignore-case?
    >r tuck r> ?string-head
    [ <parse-results> ] [ 2drop nil ] if ;

: 1token ( n -- parser ) 1string token ;

