The Curry string classifier is a simple tool to process strings containing Curry source code. The source string is classified into the following categories:
For an example to use the state scanner cf. addtypes, the tool to add function types to a given program.
data Token
The different categories to classify the source code.
Constructors:
SmallComment
:: String -> Token
BigComment
:: String -> Token
Text
:: String -> Token
Letter
:: String -> Token
Code
:: String -> Token
ModuleHead
:: String -> Token
Meta
:: String -> Token
type Tokens
= [Token]
isSmallComment
:: Token -> Bool
test for category "SmallComment"
isBigComment
:: Token -> Bool
test for category "BigComment"
test if given token is a comment (big or small)
test for category "Text" (String)
test for category "Letter" (Char)
test for category "Code"
isModuleHead
:: Token -> Bool
test for category "ModuleHead", ie imports and operator declarations
test for category "Meta", ie between {+ and +}
Divides the given string into the six categories.
For applications it is important to know whether a given part of
code is at the beginning of a line or in the middle. The state scanner
organizes the code in such a way that every string categorized as
"Code" balways/b
starts in the middle of a line.
plainCode
:: [Token] -> String
Yields the program code without comments (but with the line breaks for small comments).
Inverse function of scan, i.e., unscan (scan x) = x. unscan is used to yield a program after changing the list of tokens.
readScan
:: String -> IO [Token]
return tokens for given filename
test whether (unscan . scan) is identity