# optP -- making a parser optional

## Synopsis

• Usage:
optP p
• Inputs:
• p,
• Outputs:
• , a parser that accepts tokens accepted by p and returns the value returned by p, or accepts the empty sequence of tokens and returns the symbol nil. It prefers to do the former.

## Description

After the first token, the parser is no slower than p would have been.

 i1 : (optP constParser "abc" : charAnalyzer) "abc" o1 = abc i2 : (optP constParser "abc" : charAnalyzer) "" o2 = nil o2 : Symbol