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

* Parser -- repetition of a parser

Synopsis

Description

i1 : (* constParser "abc" : charAnalyzer) "abcabcabc"

o1 = (abc, abc, abc)

o1 : Sequence

Code

../../../../../Macaulay2/packages/Parsing.m2:130:13-141:86: --source code:
*Parser := p -> (
     f := (vals,current) -> new Parser from (c -> (
               if c === null then (
                    if current === null then vals
                    else if (val := current null) =!= null then append(vals,val)
                    )
               else (
                    if current === null then (f(vals,p)) c
                    else (
                         q := current c;
                         if q =!= null then return f(vals,q);
                         if (val = current null) =!= null then (f(append(vals,val),)) c))))

See also

Ways to use this method: