Added haddock documentation

This commit is contained in:
macocianradu
2021-11-30 22:33:44 +01:00
parent 70baa17a4e
commit ff25395b68
18 changed files with 136 additions and 73 deletions

View File

@@ -10,19 +10,22 @@ import Data.Text
type Parser = Parsec Void Text
-- |Auxiliary parser that eliminates trailing white space
spaceConsumer :: Parser ()
spaceConsumer = L.space space1 (L.skipLineComment "//") (L.skipBlockComment "/*" "*/")
-- |Auxiliary parser that runs a parser and eliminates trailing white space
lexeme :: Parser a -> Parser a
lexeme = L.lexeme spaceConsumer
-- |Parses a description in Rosetta into a String
descriptionParser :: Parser String
descriptionParser =
do
_ <- string "<\""
lexeme $ anySingle `manyTill` string "\">"
-- |Parses a pascal case name into a String (PascalCase)
pascalNameParser :: Parser String
pascalNameParser =
do
@@ -30,6 +33,7 @@ pascalNameParser =
rest <- lexeme $ many allowedChars
if first:rest `notElem` restrictedNames then return (first:rest) else fail ((first:rest) ++ " is a restricted name")
-- |Parses a camel case name into a String (camelCase)
camelNameParser :: Parser String
camelNameParser =
do
@@ -37,6 +41,7 @@ camelNameParser =
rest <- lexeme $ many allowedChars
if first:rest `notElem` restrictedNames then return (first:rest) else fail ((first:rest) ++ " is a restricted name")
-- |Parses any name that starts with a letter or '_' into a String
nameParser :: Parser String
nameParser =
do
@@ -44,9 +49,12 @@ nameParser =
rest <- lexeme $ many allowedChars
if first:rest `notElem` restrictedNames then return (first:rest) else fail ((first:rest) ++ " is a restricted name")
-- |Parses a character allowed in names in Rosetta into a Char
allowedChars :: Parser Char
allowedChars = letterChar <|> digitChar <|> char '_'
-- |List of restricted names used by Rosetta
restrictedNames :: [String]
restrictedNames = [
"displayName",