Object-oriented Parser System
v3.6

mops
Class Parser

Object
  extended by Parser

public class Parser
extends Object

wraps a ParserFunction. Encapsulates monadic LL(n) parser building blocks.

Version:
1.2.0

Field Summary
static Parser get
          a parser which succeeds with the current input as a value.
protected  ParserFunction parserFunction
           
 
Constructor Summary
Parser(ParserFunction parserFunction)
           
 
Method Summary
 Parser andThen(Scope b)
          sequential execution: create a parser which will apply the receiver and, if successful, pass the result value to the argument and apply the resulting parser.
static Parser fail(String message)
          create a parser which fails with a message.
static Object foldl(Object value, Object list)
          applies a list of functions to a value.
 Parser many()
          create a parser which will apply the receiver as often as possible and return all results (or none) as an ArrayList.
 Parser optional(Object value)
          create a parser which will apply the receiver and, if it fails, succeed with the given value.
 Parser orElse(Parser b)
          alternative execution: create a parser which will apply the receiver and, if it fails, the argument.
 Result parse(Input input)
          apply the parser function to advance in the input.
static Parser put(Object value, Input input)
          create a parser which succeeds with the given value and input.
 Parser some()
          create a parser which will apply the receiver at least once and return all results as an ArrayList.
static Parser succeed(Object value)
          create a parser which succeeds and returns a value.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parserFunction

protected final ParserFunction parserFunction

get

public static final Parser get
a parser which succeeds with the current input as a value.

Constructor Detail

Parser

public Parser(ParserFunction parserFunction)
Method Detail

parse

public Result parse(Input input)
apply the parser function to advance in the input.


succeed

public static Parser succeed(Object value)
create a parser which succeeds and returns a value.


fail

public static Parser fail(String message)
create a parser which fails with a message.


put

public static Parser put(Object value,
                         Input input)
create a parser which succeeds with the given value and input.


andThen

public Parser andThen(Scope b)
sequential execution: create a parser which will apply the receiver and, if successful, pass the result value to the argument and apply the resulting parser.


orElse

public Parser orElse(Parser b)
alternative execution: create a parser which will apply the receiver and, if it fails, the argument.


optional

public Parser optional(Object value)
create a parser which will apply the receiver and, if it fails, succeed with the given value.


some

public Parser some()
create a parser which will apply the receiver at least once and return all results as an ArrayList.


many

public Parser many()
create a parser which will apply the receiver as often as possible and return all results (or none) as an ArrayList.


foldl

public static Object foldl(Object value,
                           Object list)
applies a list of functions to a value.



(c) 2008 Axel T. Schreiner