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