Parser fixes:
- Braces instead of parens for `inputValueDefinitions`. - Rename `bool` -> `booleanValue`. - Some code rearrangements.
This commit is contained in:
parent
e74ee640a8
commit
da97387042
@ -158,7 +158,7 @@ value = ValueVariable <$> variable
|
|||||||
-- TODO: Handle maxBound, Int32 in spec.
|
-- TODO: Handle maxBound, Int32 in spec.
|
||||||
<|> ValueInt <$> tok (signed decimal)
|
<|> ValueInt <$> tok (signed decimal)
|
||||||
<|> ValueFloat <$> tok (signed double)
|
<|> ValueFloat <$> tok (signed double)
|
||||||
<|> ValueBoolean <$> bool
|
<|> ValueBoolean <$> booleanValue
|
||||||
<|> ValueString <$> stringValue
|
<|> ValueString <$> stringValue
|
||||||
-- `true` and `false` have been tried before
|
-- `true` and `false` have been tried before
|
||||||
<|> ValueEnum <$> name
|
<|> ValueEnum <$> name
|
||||||
@ -166,6 +166,9 @@ value = ValueVariable <$> variable
|
|||||||
<|> ValueObject <$> objectValue
|
<|> ValueObject <$> objectValue
|
||||||
<?> "value error!"
|
<?> "value error!"
|
||||||
|
|
||||||
|
booleanValue :: Parser Bool
|
||||||
|
booleanValue = True <$ tok "true"
|
||||||
|
<|> False <$ tok "false"
|
||||||
|
|
||||||
stringValue :: Parser StringValue
|
stringValue :: Parser StringValue
|
||||||
stringValue = StringValue <$> quotes (T.foldl' step mempty <$> takeText)
|
stringValue = StringValue <$> quotes (T.foldl' step mempty <$> takeText)
|
||||||
@ -188,10 +191,6 @@ objectValue = ObjectValue <$> braces (many objectField)
|
|||||||
objectField :: Parser ObjectField
|
objectField :: Parser ObjectField
|
||||||
objectField = ObjectField <$> name <* tok ":" <*> value
|
objectField = ObjectField <$> name <* tok ":" <*> value
|
||||||
|
|
||||||
bool :: Parser Bool
|
|
||||||
bool = True <$ tok "true"
|
|
||||||
<|> False <$ tok "false"
|
|
||||||
|
|
||||||
-- * Directives
|
-- * Directives
|
||||||
|
|
||||||
directives :: Parser [Directive]
|
directives :: Parser [Directive]
|
||||||
@ -256,17 +255,7 @@ fieldDefinition = FieldDefinition
|
|||||||
<*> type_
|
<*> type_
|
||||||
|
|
||||||
argumentsDefinition :: Parser ArgumentsDefinition
|
argumentsDefinition :: Parser ArgumentsDefinition
|
||||||
argumentsDefinition = inputValueDefinitions
|
argumentsDefinition = parens $ many1 inputValueDefinition
|
||||||
|
|
||||||
inputValueDefinitions :: Parser [InputValueDefinition]
|
|
||||||
inputValueDefinitions = parens $ many1 inputValueDefinition
|
|
||||||
|
|
||||||
inputValueDefinition :: Parser InputValueDefinition
|
|
||||||
inputValueDefinition = InputValueDefinition
|
|
||||||
<$> name
|
|
||||||
<* tok ":"
|
|
||||||
<*> type_
|
|
||||||
<*> optional defaultValue
|
|
||||||
|
|
||||||
interfaceTypeDefinition :: Parser InterfaceTypeDefinition
|
interfaceTypeDefinition :: Parser InterfaceTypeDefinition
|
||||||
interfaceTypeDefinition = InterfaceTypeDefinition
|
interfaceTypeDefinition = InterfaceTypeDefinition
|
||||||
@ -307,6 +296,16 @@ inputObjectTypeDefinition = InputObjectTypeDefinition
|
|||||||
<*> name
|
<*> name
|
||||||
<*> inputValueDefinitions
|
<*> inputValueDefinitions
|
||||||
|
|
||||||
|
inputValueDefinitions :: Parser [InputValueDefinition]
|
||||||
|
inputValueDefinitions = braces $ many1 inputValueDefinition
|
||||||
|
|
||||||
|
inputValueDefinition :: Parser InputValueDefinition
|
||||||
|
inputValueDefinition = InputValueDefinition
|
||||||
|
<$> name
|
||||||
|
<* tok ":"
|
||||||
|
<*> type_
|
||||||
|
<*> optional defaultValue
|
||||||
|
|
||||||
typeExtensionDefinition :: Parser TypeExtensionDefinition
|
typeExtensionDefinition :: Parser TypeExtensionDefinition
|
||||||
typeExtensionDefinition = TypeExtensionDefinition
|
typeExtensionDefinition = TypeExtensionDefinition
|
||||||
<$ tok "extend"
|
<$ tok "extend"
|
||||||
|
Loading…
Reference in New Issue
Block a user