pobs.parser
Class PRepeat

java.lang.Object
  extended bypobs.PParser
      extended bypobs.parser.PRepeat
All Implemented Interfaces:
PObject
Direct Known Subclasses:
PKleene, PMultiple

public class PRepeat
extends PParser

Non-terminal parser which matches the same parser multiple times, optionally limited. Uses skip directive. BNF: this := parser[min, max] (where min is the minimum number of repeats required and max is the maximum number of repeats allowed)

Author:
Martijn W. van der Lee

Field Summary
static long INFINITE
          Repeat upto any number of times.
 
Constructor Summary
PRepeat(PObject parser)
          Stub constructor specifying one-or-more repetitions.
PRepeat(PObject parser, long count)
          Stub constructor allow specification an exact number of repetitions.
PRepeat(PObject parser, long min, long max)
          Constructor allowing specification of a lower and upper boundary to the number of repetitions.
 
Method Summary
 PMatch parse(PScanner input, long begin, PContext context)
           
 
Methods inherited from class pobs.PParser
addControl, getErrorInfo, process, setErrorInfo, setMatchAction, setMismatchAction
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INFINITE

public static final long INFINITE
Repeat upto any number of times. Though this field specifies a fixed number of repetitions, it is for all practical purposes infinite.

See Also:
Constant Field Values
Constructor Detail

PRepeat

public PRepeat(PObject parser)
Stub constructor specifying one-or-more repetitions.


PRepeat

public PRepeat(PObject parser,
               long count)
Stub constructor allow specification an exact number of repetitions.

Parameters:
parser - the parser to be repeated
count - the exact number of repetitions required.

PRepeat

public PRepeat(PObject parser,
               long min,
               long max)
Constructor allowing specification of a lower and upper boundary to the number of repetitions.

Parameters:
parser - the parser to be repeated
min - the minimum number of repetitions required.
max - the maximum number of repetitions required.
Method Detail

parse

public PMatch parse(PScanner input,
                    long begin,
                    PContext context)
Parameters:
input - Input to be parsed.
begin - Index of first character of input to be parsed.
context - Parsing context.
Returns:
Parsing result.