regex-applicative-0.3.0.2: Regex-based parsing with applicative interface

Stabilityexperimental
MaintainerRoman Cheplyaka <roma@ro-che.info>
Safe HaskellSafe-Inferred

Text.Regex.Applicative.Object

Description

This is a low-level interface to the regex engine.

Synopsis

Documentation

data ReObject s r Source

The state of the engine is represented as a "regex object" of type ReObject s r, where s is the type of symbols and r is the result type (as in the RE type). Think of ReObject as a collection of Threads ordered by priority. E.g. threads generated by the left part of <|> come before the threads generated by the right part.

compile :: RE s r -> ReObject s rSource

Compile a regular expression into a regular expression object

emptyObject :: ReObject s rSource

Empty object (with no threads)

data Thread s r Source

A thread either is a result or corresponds to a symbol in the regular expression, which is expected by that thread.

threads :: ReObject s r -> [Thread s r]Source

List of all threads of an object. Each non-result thread has a unique id.

failed :: ReObject s r -> BoolSource

Check if the object has no threads. In that case it never will produce any new threads as a result of step.

isResult :: Thread s r -> BoolSource

Check whether a thread is a result thread

getResult :: Thread s r -> Maybe rSource

Return the result of a result thread, or Nothing if it's not a result thread

results :: ReObject s r -> [r]Source

Extract the result values from all the result threads of an object

threadId :: Thread s r -> Maybe ThreadIdSource

Returns thread identifier. This will be Just for ordinary threads and Nothing for results.

step :: s -> ReObject s r -> ReObject s rSource

Feed a symbol into a regex object

stepThread :: s -> Thread s r -> [Thread s r]Source

Feed a symbol into a non-result thread. It is an error to call stepThread on a result thread.

fromThreads :: [Thread s r] -> ReObject s rSource

Create an object from a list of threads. It is recommended that all threads come from the same ReObject, unless you know what you're doing. However, it should be safe to filter out or rearrange threads.

addThread :: Thread s r -> ReObject s r -> ReObject s rSource

Add a thread to an object. The new thread will have lower priority than the threads which are already in the object.

If a (non-result) thread with the same id already exists in the object, the object is not changed.