finished generator for basic types, enums and functions.

Functions still need to print a body
This commit is contained in:
macocianradu
2021-11-12 03:05:34 +01:00
parent 045ae7049e
commit 40f6fb24b7
20 changed files with 224 additions and 63 deletions

View File

@@ -27,19 +27,33 @@ pascalNameParser :: Parser String
pascalNameParser =
do
first <- upperChar
rest <- lexeme $ many (letterChar <|> digitChar <|> char '_')
return (first : rest)
rest <- lexeme $ many allowedChars
if first:rest `notElem` restrictedNames then return (first:rest) else fail ((first:rest) ++ " is a restricted name")
camelNameParser :: Parser String
camelNameParser =
do
first <- lowerChar
rest <- lexeme $ many (letterChar <|> digitChar <|> char '_')
return (first : rest)
rest <- lexeme $ many allowedChars
if first:rest `notElem` restrictedNames then return (first:rest) else fail ((first:rest) ++ " is a restricted name")
nameParser :: Parser String
nameParser =
do
first <- letterChar <|> char '_'
rest <- lexeme $ many (letterChar <|> digitChar <|> char '_')
return (first:rest)
rest <- lexeme $ many allowedChars
if first:rest `notElem` restrictedNames then return (first:rest) else fail ((first:rest) ++ " is a restricted name")
allowedChars :: Parser Char
allowedChars = letterChar <|> digitChar <|> char '_'
restrictedNames :: [String]
restrictedNames = [
"displayName",
"enum",
"func",
"type",
"extends",
"inputs",
"output"
]