LParse-0.2.2.2: A continuation-based parser library

Copyright(c) Marcus Völker 2017
LicenseMIT
Maintainermarcus.voelker@rwth-aachen.de
Safe HaskellSafe
LanguageHaskell2010

Text.LParse.Atomics

Description

This module implements LParse's atomic parsers, i.e., parsers that are not built up from other parsers.

Synopsis

Documentation

noop :: Parser r t () Source #

A parser that always succeeds, parses nothing and returns unit

full :: Parser r [t] [t] Source #

A parser that consumes the whole input and returns it unchanged

discard :: Parser r [t] () Source #

A parser that consumes the whole input and discards it, successfully

eoi :: Parser r [t] () Source #

A parser that parses nothing, but only succeeds if the input is empty

tokenParse :: TokenStream s => (t -> a) -> Parser r (s t) a Source #

Extracts the first token from the input and applies the given function to it

tokenReturn :: TokenStream s => Parser r (s a) a Source #

Consumes and returns the first token of the input

consume :: (Eq t, Show (s t), TokenStream s) => s t -> Parser r (s t) () Source #

Succeeds exactly if the input begins with the given sequence. On success, consumes that sequence

consumeSingle :: (Eq t, Show t, TokenStream s) => t -> Parser r (s t) () Source #

Succeeds exactly if the input begins with the given token. On success, consumes that token

digit :: Parser r String Integer Source #

Extracts the first digit and returns it

letter :: Parser r String Char Source #

Extracts the first digit and returns it

word :: Parser r String String Source #

Extracts the first word (i.e. contiguous string of letters) from the input and returns it

integer :: Parser r String Integer Source #

Extracts the first integer (i.e. contiguous string of digits) from the input and returns it

peek :: TokenStream s => (t -> Bool) -> String -> Parser r (s t) () Source #

Succeeds if the first token matches the given function, without consuming it

success :: (t -> (a, t)) -> Parser r t a Source #

A parser that always succeeds with the given function

bDigit :: Integer -> Parser r Integer Integer Source #

Parses an integer by removing a single digit in the given base from it. Zero is considered to have no digits

bDigits :: Integer -> Parser r Integer [Integer] Source #

Parses an integer by removing a single digit in the given base from it. Zero is considered to have no digits