next | previous | forward | backward | up | top | index | toc | Macaulay2 website
Parsing > Parser > optionalSignParser

optionalSignParser -- a parser that accepts an optional plus sign or minus sign

Description

The return value is either 1 or -1, depending on the indicated sign.

i1 : (optionalSignParser @ constParser "abc" : charAnalyzer) "abc"

o1 = (1, abc)

o1 : Sequence
i2 : (optionalSignParser @ constParser "abc" : charAnalyzer) "+abc"

o2 = (1, abc)

o2 : Sequence
i3 : (optionalSignParser @ constParser "abc" : charAnalyzer) "-abc"

o3 = (-1, abc)

o3 : Sequence

Code

../../../../../../../Macaulay2/packages/Parsing.m2:157:31-157:135: --source code:
optionalSignParser = Parser(c -> if c === null then 1 else if c === "-" then terminalParser(-1) else if c === "+" then terminalParser 1)

See also

For the programmer

The object optionalSignParser is a parser.