a simple regex-based scanner interpreter for prototyping scanners
Moduleregex-1.1.0.2Haskell2010
Text.RE.Tools.Lex
- 1 type
- 1 class
- 4 values
- Packageregex-1.1.0.2
- Exports6
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceLex.lhs
Find
2 declarationsThe Lex toolkit uses REs to identify tokens in a file, returning a list of tokens.
See the Regex Tools tutorial at http://re-tutorial-tools.regex.uk
a higher order version of alex parameterised over the matchOnce
function
IsRegex
4 declarationsthe IsRegex class allows polymorhic tools to be written that will work with a variety of regex back ends and text types
Methods
matchOnce :: re -> s -> Match sfinding the first match
matchMany :: re -> s -> Matches sfinding all matches
makeRegex :: (Functor m, Monad m, MonadFail m) => s -> m recompiling an RE, failing if the RE is not well formed
makeRegexWith :: (Functor m, Monad m, MonadFail m) => SimpleREOptions -> s -> m recomiling an RE, specifying the SimpleREOptions
makeSearchReplace :: (Functor m, Monad m, MonadFail m, IsRegex re s) => s -> s -> m (SearchReplace re s)compiling a SearchReplace template from the RE text and the template Text, failing if they are not well formed
makeSearchReplaceWith :: (Functor m, Monad m, MonadFail m, IsRegex re s) => SimpleREOptions -> s -> s -> m (SearchReplace re s)compiling a SearchReplace template specifying the SimpleREOptions for the RE
makeEscaped :: (Functor m, Monad m, MonadFail m) => (s -> s) -> s -> m reincorporate an escaped string into a compiled RE with the default options
makeEscapedWith :: (Functor m, Monad m, MonadFail m) => SimpleREOptions -> (s -> s) -> s -> m reincorporate an escaped string into a compiled RE with the specified SimpleREOptions
regexSource :: re -> sextract the text of the RE from the RE
Instances6IsRegex
IsRegex RE ByteStringDefined in regex-1.1.0.2 · Text.RE.TDFA.ByteString · orphanIsRegex RE ByteStringDefined in regex-1.1.0.2 · Text.RE.TDFA.ByteString.Lazy · orphanIsRegex RE StringDefined in regex-1.1.0.2 · Text.RE.TDFA.String · orphanIsRegex RE TextDefined in regex-1.1.0.2 · Text.RE.TDFA.Text · orphanIsRegex RE TextDefined in regex-1.1.0.2 · Text.RE.TDFA.Text.Lazy · orphanIsRegex RE (Seq Char)Defined in regex-1.1.0.2 · Text.RE.TDFA.Sequence · orphan
contains a compiled RE and replacement template
Constructors
SearchReplacegetSearch :: !rethe RE to match a string to replace
getTemplate :: !sthe replacement template with ${cap} used to identify a capture (by number or name if one was given) and
$$being used to escape a single $
Instances2Functor, Show
Functor (SearchReplace re)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.SearchReplace(Show re, Show s) => Show (SearchReplace re s)Defined in regex-1.1.0.2 · Text.RE.ZeInternals.Types.SearchReplace
search and replace all matches in the argument text; e.g., this function will convert every YYYY-MM-DD format date in its argument text into a DD/MM/YYYY date:
searchReplaceAll [ed|${y}([0-9]{4})-0*${m}([0-9]{2})-0*${d}([0-9]{2})///${d}/${m}/${y}|]search and replace the first occurrence only (if any) in the input text
e.g., to prefix the first string of four hex digits in the imput text,
if any, with 0x:
searchReplaceFirst [ed|[0-9A-Fa-f]{4}///0x$0|]Replace
0 declarationsmodule Text.RE.Replace