Parser Combinator for R


[Up] [Top]

Documentation for package ‘Ramble’ version 0.1.1

Help Pages

Ramble-package Ramble is a parser generator using combinatory parsers.
%alt% '%alt%' is the infix notation for the 'alt' function.
%then% '%then%' is the infix operator for the then combinator.
%thentree% '%thentree%' is the infix operator for the then combinator, and it is the preferred way to use the 'thentree' operator.
%using% '%using%' is the infix operator for using
Alpha Alpha checks for single alphabet character
AlphaNum AlphaNum checks for a single alphanumeric character
alt 'alt' combinator is similar to alternation in BNF. the parser '(alt(p1, p2))' recognises anything that 'p1' or 'p2' would. The approach taken in this parser follows (Fairbairn86), in which either is interpretted in a sequential (or exclusive) manner, returning the result of the first parser to succeed, and failure if neither does.
Digit Digit checks for single digit
ident 'ident' is a parser which matches zero or more alphanumeric characters.
identifier 'identifier' creates an identifier
item 'item' is a parser that consumes the first character of the string and returns the rest. If it cannot consume a single character from the string, it will emit the empty list, indicating the parser has failed.
literal 'literal' is a parser for single symbols. It will attempt to match the single symbol with the first character in the string.
Lower Lower checks for single lower case character
many 'many' matches 0 or more of pattern 'p'. In BNF notation, repetition occurs often enough to merit its own abbreviation. When zero or more repetitions of a phrase 'p' are admissible, we simply write 'p*'. The 'many' combinator corresponds directly to this operator, and is defined in much the same way.
maybe 'maybe' matches 0 or 1 of pattern 'p'. In EBNF notation, this corresponds to a question mark ('?').
nat 'nat' is a parser which matches one or more numeric characters.
natural 'natural' creates a token parser for natural numbers
package-ramble Ramble is a parser generator using combinatory parsers.
Ramble Ramble is a parser generator using combinatory parsers.
ramble Ramble is a parser generator using combinatory parsers.
satisfy 'satisfy' is a function which allows us to make parsers that recognise single symbols.
some 'some' matches 1 or more of pattern 'p'. in BNF notation, repetition occurs often enough to merit its own abbreviation. When zero or more repetitions of a phrase 'p' are admissible, we simply write 'p+'. The 'some' combinator corresponds directly to this operator, and is defined in much the same way.
space 'space' matches zero or more space characters.
SpaceCheck SpaceCheck checks for a single space character
String 'String' is a combinator which allows us to build parsers which recognise strings of symbols, rather than just single symbols
succeed 'succeed' is based on the empty string symbol in the BNF notation The 'succeed' parser always succeeds, without actually consuming any input string. Since the outcome of succeed does not depend on its input, its result value must be pre-detemined, so it is included as an extra parameter.
symbol 'symbol' creates a token for a symbol
then 'then' combinator corresponds to sequencing in BNF. The parser '(then(p1, p2))' recognises anything that 'p1' and 'p2' would if placed in succession.
thentree 'thentree' keeps the full tree representation of the results of parsing. Otherwise, it is identical to 'then'.
token 'token' is a new primitive that ignores any space before and after applying a parser to a token.
Unlist Unlist is the same as unlist, but doesn't recurse all the way to preserve the type. This function is not well optimised.
Upper Upper checks for a single upper case character
using 'using' combinator allows us to manipulate results from a parser, for example building a parse tree. The parser '(p %using% f)' has the same behaviour as the parser 'p', except that the function 'f' is applied to each of its result values.