Learn R Programming

Ramble (version 0.1.1)

Parser Combinator for R

Description

Parser generator for R using combinatory parsers. It is inspired by combinatory parsers developed in Haskell.

Copy Link

Version

Install

install.packages('Ramble')

Monthly Downloads

176

Version

0.1.1

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Chapman Siu

Last Published

October 29th, 2016

Functions in Ramble (0.1.1)

identifier

identifier creates an identifier
Digit

Digit checks for single digit
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.
%using%

%using% is the infix operator for using
%thentree%

%thentree% is the infix operator for the then combinator, and it is the preferred way to use the thentree operator.
Alpha

Alpha checks for single alphabet character
AlphaNum

AlphaNum checks for a single alphanumeric character
ident

ident is a parser which matches zero or more alphanumeric characters.
%alt%

%alt% is the infix notation for the alt function.
%then%

%then% is the infix operator for the then combinator.
satisfy

satisfy is a function which allows us to make parsers that recognise single symbols.
natural

natural creates a token parser for natural numbers
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.
Ramble

Ramble is a parser generator using combinatory parsers.
Lower

Lower checks for single lower case character
maybe

maybe matches 0 or 1 of pattern p. In EBNF notation, this corresponds to a question mark ('?').
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.
nat

nat is a parser which matches one or more numeric characters.
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.
Unlist

Unlist is the same as unlist, but doesn't recurse all the way to preserve the type. This function is not well optimised.
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.
String

String is a combinator which allows us to build parsers which recognise strings of symbols, rather than just single symbols
symbol

symbol creates a token for a symbol
space

space matches zero or more space characters.
then

then combinator corresponds to sequencing in BNF. The parser (then(p1, p2)) recognises anything that p1 and p2 would if placed in succession.
Upper

Upper checks for a single upper case character
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.
SpaceCheck

SpaceCheck checks for a single space 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.