module Pars::Parse
Overview
Tools for creating commonly useful Parser
instances.
Extended Modules
Defined in:
pars/parse.crInstance Method Summary
- #alphanumeric
-
#byte(byte : UInt8) : Parser(UInt8)
Parser that matches for a specific byte at the parse head.
-
#byte : Parser(UInt8)
Parser that return the byte vaue at the parse head.
-
#byte_if(expected = nil, &block : UInt8 -> Bool) : Parser(UInt8)
Parser that return the context head if it satisfies block.
-
#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. -
#char(char : Char) : Parser(Char)
Parser that matches for a specific char at the parse head.
-
#char : Parser(Char)
Parser that returns the parse head as a
Char
. -
#char_if(expected = nil, &block : Char -> Bool) : Parser(Char)
Parser that return the context head if it satisfies block.
-
#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.
-
#const(value : T) : Parser(T) forall T
Always succeeds with value and does not consume any input.
-
#decimal
Parses a fractional number as a String.
-
#digit
Parses a digit as a character.
-
#eq(value : T) : Parser(T) forall T
Parser that tests equivalence to value at the parse head.
-
#integer
Parses an integer as a String.
-
#letter
Parses a character in the alphabet regardless of case.
-
#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. -
#lowercase
Parses a character of the lowercase alphabet.
-
#no_char_of(string_or_list : String | Enumerable(Char)) : Parser(Char)
Functions identically to
Parse.one_char_of
, but reverses the expected input. - #non_empty_list(item : Parser(A), delimiter : Parser(B)) : Parser(Array(A)) forall A, B
-
#number
Parses a number as a String.
-
#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 strings
. -
#string(string : String) : Parser(String)
Creates a
Parser(String)
that looks at the current parse position and expects the array of characters in the strings
(s.chars
) to be consecutively present. -
#uppercase
Parses a character of the uppercase alphabet.
- #whitespace
-
#word
Parses a full word of at least one character.
Macro Summary
-
do(body)
Provides a notation for building complex parsers that combine the result of a number of component parsers.
Instance Method Detail
Parser that matches for a specific byte at the parse head.
Parser that return the context head if it satisfies block.
expected can be optionally specified for providing a human friendly ParseError on fail.
Creates a Parser(Bytes)
that looks at the current parse position and
expects a series of bytes to be consecutively present.
Parser that matches for a specific char at the parse head.
Parser that return the context head if it satisfies block.
expected can be optionally specified for providing a human friendly ParseError on fail.
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.
Always succeeds with value and does not consume any input.
Parser that tests equivalence to value at the parse head.
If equivalent value itself is returned and the parse head progresses.
Creates a Parser(Array(T))
that will continue to parse with parser
delimited by delimter until an error with either occurs.
Functions identically to Parse.one_char_of
, but reverses the expected
input. If the current character is present in s
, then the parse fails.
Creates a Parser(Char)
that looks at the current parse position and
expects the current character to be present in the string s
.
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.
Macro Detail
Provides a notation for building complex parsers that combine the result of a number of component parsers.