atto/text_util
Functions
pub fn binary() -> Parser(Int, String, String, a, b)
Parse a binary number. Does not include a prefix such as 0b.
Examples
{
use <- drop(atto.match("0b"))
binary()
}
|> run(text.new("0b10010"), Nil)
// -> Ok(18)
pub fn char_lit() -> Parser(String, String, String, a, b)
Parse a character literal as defined by the Gleam language.
pub fn decimal() -> Parser(Int, String, String, a, b)
Parse a decimal number. See signed to parse a signed number.
Examples
signed(decimal(), int.negate)
|> run(text.new("-123"), Nil)
// -> Ok(-123)
pub fn float(
sign sign: Bool,
) -> Parser(Float, String, String, a, b)
Parse a float number. See signed to parse a signed number.
Examples
signed(float(), float.negate)
|> run(text.new("-123.456"), Nil)
// -> Ok(-123.456)
pub fn hexadecimal() -> Parser(Int, String, String, a, b)
Parse an octal number. Does not include a prefix such as 0x.
Examples
{
use <- drop(atto.match("0x"))
hexadecimal()
}
|> run(text.new("0x1a"), Nil)
// -> Ok(26)
pub fn hspaces() -> Parser(String, String, String, a, b)
Parse zero or more horizontal ASCII whitespace characters.
pub fn hspaces1() -> Parser(String, String, String, a, b)
Parse one or more horizontal ASCII whitespace characters.
pub fn number() -> Parser(Float, String, String, a, b)
Parse a signed decimal or float number.
pub fn signed(
p: Parser(a, String, String, b, c),
negate: fn(a) -> a,
) -> Parser(a, String, String, b, c)
Given a parser for a number and a negation function, parse a signed number.
pub fn simple_char_lit() -> Parser(String, String, a, b, c)
Parse a simple character literal, eg one without escape sequences.
pub fn spaces() -> Parser(String, String, String, a, b)
Parse zero or more ASCII whitespace characters.
pub fn spaces1() -> Parser(String, String, String, a, b)
Parse one or more ASCII whitespace characters.
pub fn string_lit(
char: Parser(String, String, String, a, b),
) -> Parser(String, String, String, a, b)
Parse a string literal using the given character parser.