lux/lexer

Types

Lexer

(type: (Lexer a)
  (-> lux;Text (lux/data/error;Error [lux;Text a])))

Structs

Applicative<Lexer>

(lux/control/applicative;Applicative Lexer)

Functor<Lexer>

(lux/control/functor;Functor Lexer)

Monad<Lexer>

(lux/control/monad;Monad Lexer)

Values

(&_ left right)

(All [a b] (-> (Lexer a) (Lexer b) (Lexer a)))

(_& left right)

(All [a b] (-> (Lexer a) (Lexer b) (Lexer b)))

alpha

Only lex alphabetic characters.

(Lexer lux;Char)

alpha-num

Only lex alphanumeric characters.

(Lexer lux;Char)

(alt left right)

Heterogeneous alternative combinator.

(All [a b] (-> (Lexer a) (Lexer b) (Lexer (| a b))))

any

Just returns the next character without applying any logic.

(Lexer lux;Char)

(assert message test)

Fails with the given message if the test is false.

(-> lux;Text lux;Bool (Lexer lux;Unit))

(at-least n p)

Lex at least N times.

(All [a] (-> lux;Nat (Lexer a) (Lexer (lux;List a))))

(at-most n p)

Lex at most N times.

(All [a] (-> lux;Nat (Lexer a) (Lexer (lux;List a))))

(between from to p)

Lex between N and M times.

(All [a] (-> lux;Nat lux;Nat (Lexer a) (Lexer (lux;List a))))

(char test)

Lex a character if it matches the given sample.

(-> lux;Char (Lexer lux;Char))

(char-range bottom top)

Only lex characters within a range.

(-> lux;Char lux;Char (Lexer lux;Char))

(codec codec lexer)

Lex a token by means of a codec.

(All [a] (-> (lux/control/codec;Codec lux;Text a) (Lexer lux;Text) (Lexer a)))

(default value lexer)

If the given lexer fails, this lexer will succeed with the provided value.

(All [a] (-> a (Lexer a) (Lexer a)))

digit

Only lex decimal characters.

(Lexer lux;Char)

(either left right)

Homogeneous alternative combinator.

(All [a] (-> (Lexer a) (Lexer a) (Lexer a)))

(enclosed [start end] lexer)

(All [a] (-> [lux;Text lux;Text] (Lexer a) (Lexer a)))

end

Ensure the lexer's input is empty.

(Lexer lux;Unit)

end?

Ask if the lexer's input is empty.

(Lexer lux;Bool)

(exactly n p)

Lex exactly N times.

(All [a] (-> lux;Nat (Lexer a) (Lexer (lux;List a))))

(fail message)

(All [a] (-> lux;Text (Lexer a)))

get-input

Get all of the remaining input (without consuming it).

(Lexer lux;Text)

hex-digit

Only lex hexadecimal digits.

(Lexer lux;Char)

lower

Only lex lowercase characters.

(Lexer lux;Char)

(many p)

1-or-more combinator.

(All [a] (-> (Lexer a) (Lexer (lux;List a))))

(many' p)

Lex many characters as a single continuous text.

(-> (Lexer lux;Char) (Lexer lux;Text))

(none-of options)

Only lex characters that aren't part of a piece of text.

(-> lux;Text (Lexer lux;Char))

(not p)

Produce a character if the lexer fails.

(All [a] (-> (Lexer a) (Lexer lux;Char)))

(not! p)

Ensure a lexer fails.

(All [a] (-> (Lexer a) (Lexer lux;Unit)))

oct-digit

Only lex octal characters.

(Lexer lux;Char)

(one-of options)

Only lex characters that are part of a piece of text.

(-> lux;Text (Lexer lux;Char))

(opt p)

Optionality combinator.

(All [a] (-> (Lexer a) (Lexer (lux;Maybe a))))

peek

Lex the next character (without consuming it from the input).

(Lexer lux;Char)

(run lexer input)

(All [a] (-> (Lexer a) lux;Text (lux/data/error;Error a)))

(run' lexer input)

(All [a] (-> (Lexer a) lux;Text (lux/data/error;Error [lux;Text a])))

(satisfies p)

Only lex characters that satisfy a predicate.

(-> (-> lux;Char lux;Bool) (Lexer lux;Char))

(sep-by sep lexer)

Apply a lexer multiple times, checking that a separator lexer succeeds between each time.

(All [a b] (-> (Lexer b) (Lexer a) (Lexer (lux;List a))))

(seq left right)

Sequencing combinator.

(All [a b] (-> (Lexer a) (Lexer b) (Lexer [a b])))

(some p)

0-or-more combinator.

(All [a] (-> (Lexer a) (Lexer (lux;List a))))

(some' p)

Lex some characters as a single continuous text.

(-> (Lexer lux;Char) (Lexer lux;Text))

space

Only lex white-space.

(Lexer lux;Char)

(text test)

Lex a text if it matches the given sample.

(-> lux;Text (Lexer lux;Text))

upper

Only lex uppercase characters.

(Lexer lux;Char)