module

Pars::Parse

Tools for creating commonly useful Parser instances.

Instance methods

alphanumeric
Source
byte(byte : UInt8) : Parser(UInt8)

Parser that matches for a specific byte at the parse head.

Source
byte

Parser that return the byte vaue at the parse head.

Source
byte_if(expected = nil, &block : UInt8 -> Bool) : Parser(UInt8)

Parser that return the context head if it satisfies block.

expected can be optionally specified for providing a human friendly ParseError on fail.

Source
bytes(bytes : Bytes) : Parser(Bytes)

Creates a Parser(Bytes) that looks at the current parse position and expects a series of bytes to be consecutively present.

Source
char(char : Char) : Parser(Char)

Parser that matches for a specific char at the parse head.

Source
char

Parser that returns the parse head as a Char.

Source
char_if(expected = nil, &block : Char -> Bool) : Parser(Char)

Parser that return the context head if it satisfies block.

expected can be optionally specified for providing a human friendly ParseError on fail.

Source
cond(value : T, expected : T | String | Nil = nil, &block : T -> Bool) : Parser(T) forall T

Parser that succeeds with value if block evaluates to true when passed the value.

In most cases this should not be used externally and is instead a tool for composing parsers.

Source
const(value : T) : Parser(T) forall T

Always succeeds with value and does not consume any input.

Source
decimal

Parses a fractional number as a String.

Source
digit

Parses a digit as a character.

Source
eq(value : T) : Parser(T) forall T

Parser that tests equivalence to value at the parse head.

If equivalent value itself is returned and the parse head progresses.

Source
integer

Parses an integer as a String.

Source
letter

Parses a character in the alphabet regardless of case.

Source
list(item : Parser(A), delimiter : Parser(B)) : Parser(Array(A)) forall A, B

Creates a Parser(Array(T)) that will continue to parse with parser delimited by delimter until an error with either occurs.

Source
lowercase

Parses a character of the lowercase alphabet.

Source
no_char_of(string_or_list : String | Enumerable(Char)) : Parser(Char)

Functions identically to Parse.one_char_of, but reverses the expected input. If the current character is present in s, then the parse fails.

Source
non_empty_list(item : Parser(A), delimiter : Parser(B)) : Parser(Array(A)) forall A, B
Source
number

Parses a number as a String.

Source
one_char_of(string_or_list : String | Enumerable(Char)) : Parser(Char)

Creates a Parser(Char) that looks at the current parse position and expects the current character to be present in the string s.

Source
string(string : String) : Parser(String)

Creates a Parser(String) that looks at the current parse position and expects the array of characters in the string s (s.chars) to be consecutively present.

Source
uppercase

Parses a character of the uppercase alphabet.

Source
whitespace
Source
word

Parses a full word of at least one character.

Source

Macros

do(body)

Provides a notation for building complex parsers that combine the result of a number of component parsers.

Source