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

NNParser -- a parser that accepts (and returns) a natural number, one character at a time

Description

i1 : NNParser "1"

o1 = Parser[/usr/share/Macaulay2/Parsing.m2:152:39-152:101]

o1 : Parser
i2 : oo null

o2 = 1
i3 : ooo "2"

o3 = Parser[/usr/share/Macaulay2/Parsing.m2:152:39-152:101]

o3 : Parser
i4 : oo null

o4 = 12
i5 : ooo "3"

o5 = Parser[/usr/share/Macaulay2/Parsing.m2:152:39-152:101]

o5 : Parser
i6 : oo null

o6 = 123
i7 : (NNParser : charAnalyzer) "123456789123456789123456789"

o7 = 123456789123456789123456789
i8 : class oo

o8 = ZZ

o8 : Ring

Code

../Parsing.m2:153:29-153:57: --source code:
          new Parser from (c -> if digit#?c then f digit#c)
| symbol  class            value                                          location of symbol
| ------  -----            -----                                          ------------------         
| f       FunctionClosure  FunctionClosure[../Parsing.m2:152:17-152:101]  ../Parsing.m2:152:10-152:11

See also

For the programmer

The object NNParser is a parser.