Macaulay2 » Documentation
Packages » Parsing > Parser > optionalSignParser
next | previous | forward | backward | up | index | toc

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:30-157:134: --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.