mirror of
https://github.com/macocianradu/RosettaHaskellCompiler.git
synced 2026-03-18 21:10:07 +00:00
Added haddock documentation
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user