Tidied up the type of handleDirective to make it easier to use
This commit is contained in:
parent
03eab6c142
commit
d02b771572
|
@ -102,8 +102,7 @@ expandIncludes (t:ts) = expandIncludes ts >>* (t :)
|
||||||
preprocessOccam :: [Token] -> PassM [Token]
|
preprocessOccam :: [Token] -> PassM [Token]
|
||||||
preprocessOccam [] = return []
|
preprocessOccam [] = return []
|
||||||
preprocessOccam ((m, TokPreprocessor s):ts)
|
preprocessOccam ((m, TokPreprocessor s):ts)
|
||||||
= do beforeRest <- handleDirective m (stripPrefix s)
|
= handleDirective m (stripPrefix s) ts >>= preprocessOccam
|
||||||
beforeRest ts >>= preprocessOccam
|
|
||||||
where
|
where
|
||||||
stripPrefix :: String -> String
|
stripPrefix :: String -> String
|
||||||
stripPrefix (' ':cs) = stripPrefix cs
|
stripPrefix (' ':cs) = stripPrefix cs
|
||||||
|
@ -131,9 +130,12 @@ preprocessOccam (t:ts)
|
||||||
type DirectiveFunc = Meta -> [String] -> PassM ([Token] -> PassM [Token])
|
type DirectiveFunc = Meta -> [String] -> PassM ([Token] -> PassM [Token])
|
||||||
|
|
||||||
-- | Call the handler for a preprocessor directive.
|
-- | Call the handler for a preprocessor directive.
|
||||||
handleDirective :: Meta -> String -> PassM ([Token] -> PassM [Token])
|
handleDirective :: Meta -> String -> [Token] -> PassM [Token]
|
||||||
handleDirective m s = lookup s directives
|
handleDirective m s x
|
||||||
|
= do f <- lookup s directives
|
||||||
|
f x
|
||||||
where
|
where
|
||||||
|
lookup :: String -> [(Regex, DirectiveFunc)] -> PassM ([Token] -> PassM [Token])
|
||||||
-- FIXME: This should really be an error rather than a warning, but
|
-- FIXME: This should really be an error rather than a warning, but
|
||||||
-- currently we support so few preprocessor directives that this is more
|
-- currently we support so few preprocessor directives that this is more
|
||||||
-- useful.
|
-- useful.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user