Module "CurryStringClassifier.curry"

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:

Datatypes:
Token | Tokens

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:

isSmallComment  :: Token -> Bool  deterministic rigid
          test for category "SmallComment"
isBigComment  :: Token -> Bool  deterministic rigid
          test for category "BigComment"
isComment  :: Token -> Bool  deterministic 
          test if given token is a comment (big or small)
isText  :: Token -> Bool  deterministic rigid
          test for category "Text" (String)
isLetter  :: Token -> Bool  deterministic rigid
          test for category "Letter" (Char)
isCode  :: Token -> Bool  deterministic rigid
          test for category "Code"
isModuleHead  :: Token -> Bool  deterministic rigid
          test for category "ModuleHead", ie imports and operator declarations
isMeta  :: Token -> Bool  deterministic rigid
          test for category "Meta", ie between {+ and +}
scan  :: String -> [Token]  deterministic 
          Divides the given string into the six categories.
plainCode  :: [Token] -> String  deterministic flexible+rigid
          Yields the program code without comments (but with the line breaks for small comments).
unscan  :: [Token] -> String  deterministic flexible+rigid
          Inverse function of scan, i.e., unscan (scan x) = x.
readScan  :: String -> IO [Token]  deterministic 
          return tokens for given filename
testScan  :: String -> IO ()  deterministic 
          test whether (unscan .

 Imported modules:

Char
Prelude

 Exported datatypes:

Tokens

Type synonym: Tokens = [Token]


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



 Exported functions:

isSmallComment :: Token -> Bool  deterministic rigid

test for category "SmallComment"


isBigComment :: Token -> Bool  deterministic rigid

test for category "BigComment"


isComment :: Token -> Bool  deterministic 

test if given token is a comment (big or small)


isText :: Token -> Bool  deterministic rigid

test for category "Text" (String)


isLetter :: Token -> Bool  deterministic rigid

test for category "Letter" (Char)


isCode :: Token -> Bool  deterministic rigid

test for category "Code"


isModuleHead :: Token -> Bool  deterministic rigid

test for category "ModuleHead", ie imports and operator declarations


isMeta :: Token -> Bool  deterministic rigid

test for category "Meta", ie between {+ and +}


scan :: String -> [Token]  deterministic 

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.


plainCode :: [Token] -> String  deterministic flexible+rigid

Yields the program code without comments (but with the line breaks for small comments).


unscan :: [Token] -> String  deterministic flexible+rigid

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]  deterministic 

return tokens for given filename


testScan :: String -> IO ()  deterministic 

test whether (unscan . scan) is identity



Generated by CurryDoc (Version 0.4.1 of June 7, 2007) at Jun 16 17:28:12 2009