Kaya 0.5.2 reference for Parse::or

List of functions and data types in Parse

Parser<a> or(Parser<a> x, Parser<a> y)

Arguments

Usage

Create a new parser combining x and y. The new parser recognises a string which is recognised by either x or y.

decimal = or(Parse::digit,Parse::char@('.'));
// may be more clear in many situations to write this as
decimal = Parse::digit `or` Parse::char@('.');

As with Kaya's || operator, this uses short-circuit evaluation: if x parses the String successfully, y will not be used.

kaya@kayalang.org | Last modified 29 November 2011 | Supported by Durham CompSoc | Powered by Kaya