From fdf1dbfdedc34146b80c8b4211aa48f451baf546 Mon Sep 17 00:00:00 2001 From: Derek Elkins Date: Tue, 22 Jan 2008 04:06:32 +0000 Subject: [PATCH] Haddock documentation for Text.Parsec.Language --- Text/Parsec/Language.hs | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/Text/Parsec/Language.hs b/Text/Parsec/Language.hs index a987986..8f964f4 100644 --- a/Text/Parsec/Language.hs +++ b/Text/Parsec/Language.hs @@ -29,8 +29,13 @@ import Text.Parsec.Token ----------------------------------------------------------- -- Styles: haskellStyle, javaStyle ----------------------------------------------------------- + +-- | This is a minimal token definition for Haskell style languages. It +-- defines the style of comments, valid identifiers and case +-- sensitivity. It does not define any reserved words or operators. + haskellStyle :: LanguageDef st -haskellStyle= emptyDef +haskellStyle = emptyDef { commentStart = "{-" , commentEnd = "-}" , commentLine = "--" @@ -44,6 +49,10 @@ haskellStyle= emptyDef , caseSensitive = True } +-- | This is a minimal token definition for Java style languages. It +-- defines the style of comments, valid identifiers and case +-- sensitivity. It does not define any reserved words or operators. + javaStyle :: LanguageDef st javaStyle = emptyDef { commentStart = "/*" @@ -59,7 +68,14 @@ javaStyle = emptyDef ----------------------------------------------------------- -- minimal language definition ------------------------------------------------------------ +-------------------------------------------------------- + +-- TODO: This seems wrong +-- < This is the most minimal token definition. It is recommended to use +-- this definition as the basis for other definitions. @emptyDef@ has +-- no reserved names or operators, is case sensitive and doesn't accept +-- comments, identifiers or operators. + emptyDef :: LanguageDef st emptyDef = LanguageDef { commentStart = "" @@ -80,9 +96,14 @@ emptyDef = LanguageDef ----------------------------------------------------------- -- Haskell ----------------------------------------------------------- + +-- | A lexer for the haskell language. + haskell :: TokenParser st haskell = makeTokenParser haskellDef +-- | The language definition for the Haskell language. + haskellDef :: LanguageDef st haskellDef = haskell98Def { identLetter = identLetter haskell98Def <|> char '#' @@ -93,6 +114,8 @@ haskellDef = haskell98Def ] } +-- | The language definition for the language Haskell98. + haskell98Def :: LanguageDef st haskell98Def = haskellStyle { reservedOpNames= ["::","..","=","\\","|","<-","->","@","~","=>"] @@ -110,9 +133,14 @@ haskell98Def = haskellStyle ----------------------------------------------------------- -- Mondrian ----------------------------------------------------------- + +-- | A lexer for the mondrian language. + mondrian :: TokenParser st mondrian = makeTokenParser mondrianDef +-- | The language definition for the language Mondrian. + mondrianDef :: LanguageDef st mondrianDef = javaStyle { reservedNames = [ "case", "class", "default", "extends"