sdpc.parsers

Simple parsers

Here are some commonly used parsers. Also as an example for how to use the combinators.

Members

Aliases

whitespace
alias whitespace = pipe!(choice!(token!" ", token!"\n", token!"\t"))

Skip white spaces

word
alias word(alias accept = alphabet) = many!(ch!accept)

Parse a sequence of characters

ws
alias ws(alias func) = pipe!(seq!(func, skip!whitespace), wrap!"a[0]")
Undocumented in source.

Functions

identifier
auto identifier(R i)

Parse an identifier, starts with a letter or _, followed by letter, _, or digits

parse_escape1
auto parse_escape1(R i)

Parse escaped character, \n, \r, \b, \" and \\

parse_string
auto parse_string(R i)

Parse a string enclosed by a pair of quotes, and containing escape sequence

Structs

Err
struct Err(R)
Undocumented in source.
not_ch
struct not_ch(alias reject)

Match any character except those in reject

Templates

ch
template ch(alias accept)

Match any character in accept

digit
template digit(string _digits)

Parse a sequences of digits, return an array of number

number
template number(string accept = digits, int base = 10)

Parse a number

token
template token(string t)

Match a string, return the matched string

token_ws
template token_ws(string t)
Undocumented in source.

Variables

alphabet
string alphabet;
Undocumented in source.
digits
string digits;
Undocumented in source.
lower
string lower;
Undocumented in source.
upper
string upper;
Undocumented in source.

Meta