The Curry string classifier is a simple tool to process strings containing
Curry source code. The source string is classified into the following
categories:
(1) moduleHead - module interface, imports, operators
(2) code - the part where the actual program is defined
(3) big comment - parts enclosed in {- ... -}
(4) small comment - from "--" to the end of a line
(5) text - a string, i.e. text enclosed in "..."
(6) letter - the given string is the representation of a character
(7) meta - containing information for meta programming
For an example to use the state scanner cf. addtypes, the tool
to add function types to a given program.
Author: Bernd Brassel
Version: April 2005
| Exported names: |
Constructors:
BigComment
| Code
| Letter
| Meta
| ModuleHead
| SmallComment
| Text
Functions:
isBigComment
| isCode
| isComment
| isLetter
| isMeta
| isModuleHead
| isSmallComment
| isText
| plainCode
| readScan
| scan
| testScan
| unscan
| Summary of exported functions: |
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
| Imported modules: |
| Exported datatypes: |
Type synonym: Tokens = [Token]
The different categories to classify the source code.
Constructors:
:: String -> Token
:: String -> Token
:: String -> Token
:: String -> Token
:: String -> Token
:: String -> Token
:: String -> Token
| Exported functions: |
:: Token -> Bool
test for category "SmallComment"
:: Token -> Bool
test for category "BigComment"
:: Token -> Bool
test if given token is a comment (big or small)
:: Token -> Bool
test for category "Text" (String)
:: Token -> Bool
test for category "Letter" (Char)
:: Token -> Bool
test for category "Code"
:: Token -> Bool
test for category "ModuleHead", ie imports and operator declarations
:: Token -> Bool
test for category "Meta", ie between {+ and +}
:: String -> [Token]
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" always starts in the middle of a line.
:: [Token] -> String
Yields the program code without comments (but with the line breaks for small comments).
:: [Token] -> String
Inverse function of scan, i.e., unscan (scan x) = x. unscan is used to yield a program after changing the list of tokens.
:: String -> IO [Token]
return tokens for given filename
:: String -> IO ()
test whether (unscan . scan) is identity