pobs.parser
Class PList

java.lang.Object
  extended bypobs.PParser
      extended bypobs.parser.PList
All Implemented Interfaces:
PObject

public class PList
extends PParser

Matches a delimited list of items within the specified number of items. The user is responsible for making sure the item parser does not swollow the delimiter parser.

Author:
Martijn W. van der Lee

Field Summary
static long INFINITE
           
 
Constructor Summary
PList(PObject item, PObject delimiter)
          Stub constructor taking the item and delimiter parser and assuming one- or-more iterations.
PList(PObject item, PObject delimiter, long count)
          Stub constructor taking the item and delimiter parser and the exact number of items in the list.
PList(PObject item, PObject delimiter, long min, long max)
          Constructor taking the item and delimiter parser and the minimum and maximum number of items in the list.
 
Method Summary
 PMatch parse(PScanner input, long begin, PContext context)
          Matches the specified number of items in a delimited list.
 
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
See Also:
Constant Field Values
Constructor Detail

PList

public PList(PObject item,
             PObject delimiter)
Stub constructor taking the item and delimiter parser and assuming one- or-more iterations.

Parameters:
item - parser which matches the items in the list
delimiter - parser which matches the delimiters interleaving the items

PList

public PList(PObject item,
             PObject delimiter,
             long count)
Stub constructor taking the item and delimiter parser and the exact number of items in the list.

Parameters:
item - parser which matches the items in the list
delimiter - parser which matches the delimiters interleaving the items
count - exact number of items required

PList

public PList(PObject item,
             PObject delimiter,
             long min,
             long max)
Constructor taking the item and delimiter parser and the minimum and maximum number of items in the list. Current implementation constructs a POBS parser, future implementations may use dedicated code for better performance.

Parameters:
item - parser which matches the items in the list
delimiter - parser which matches the delimiters interleaving the items
min - minimum number of items required
max - maximum number of items parsed
Method Detail

parse

public PMatch parse(PScanner input,
                    long begin,
                    PContext context)
Matches the specified number of items in a delimited list. Each two items in the list must be separated by exactly one delimiter unless items are optional.

Parameters:
input - Input to be parsed.
begin - Index of first character of input to be parsed.
context - Parsing context.
Returns:
Parsing result.