Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Number value literal lookahead restrictions #601

Merged
merged 1 commit into from
Jan 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions spec/Appendix B -- Grammar Summary.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Letter :: one of
Digit :: one of
`0` `1` `2` `3` `4` `5` `6` `7` `8` `9`

IntValue :: IntegerPart [lookahead != {Digit, `.`, ExponentPart}]
IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]

IntegerPart ::
- NegativeSign? 0
Expand All @@ -79,9 +79,9 @@ NegativeSign :: -
NonZeroDigit :: Digit but not `0`

FloatValue ::
- IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, ExponentIndicator}]
- IntegerPart FractionalPart [lookahead != {Digit, `.`, ExponentIndicator}]
- IntegerPart ExponentPart [lookahead != {Digit, `.`, ExponentIndicator}]
- IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
- IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]
- IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]

FractionalPart :: . Digit+

Expand Down
26 changes: 17 additions & 9 deletions spec/Section 2 -- Language.md
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ specified as a variable. List and inputs objects may also contain variables (unl

### Int Value

IntValue :: IntegerPart [lookahead != {Digit, `.`, ExponentIndicator}]
IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}]

IntegerPart ::
- NegativeSign? 0
Expand All @@ -744,16 +744,18 @@ token is always the longest possible valid sequence. The source characters
{2}. This also means the source {00} is invalid since it can neither be
interpreted as a single token nor two {0} tokens.

An {IntValue} must not be followed by a {.} or {ExponentIndicator}. If either
follows then the token must only be interpreted as a possible {FloatValue}.
An {IntValue} must not be followed by a {`.`} or {NameStart}. If either {`.`} or
{ExponentIndicator} follows then the token must only be interpreted as a
possible {FloatValue}. No other {NameStart} character can follow. For example
the sequences `0x123` and `123L` have no valid lexical representations.


### Float Value

FloatValue ::
- IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, ExponentIndicator}]
- IntegerPart FractionalPart [lookahead != {Digit, `.`, ExponentIndicator}]
- IntegerPart ExponentPart [lookahead != {Digit, `.`, ExponentIndicator}]
- IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}]
- IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}]
- IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}]

FractionalPart :: . Digit+

Expand All @@ -772,9 +774,15 @@ token is always the longest possible valid sequence. The source characters
{1.23} cannot be interpreted as two tokens since {1.2} is followed by the
{Digit} {3}.

A {FloatValue} must not be followed by a {.} or {ExponentIndicator}. If either
follows then a parse error occurs. For example, the sequence {1.23.4} cannot be
interpreted as two tokens ({1.2}, {3.4}).
A {FloatValue} must not be followed by a {.}. For example, the sequence {1.23.4}
cannot be interpreted as two tokens ({1.2}, {3.4}).

A {FloatValue} must not be followed by a {NameStart}. For example the sequence
`0x1.2p3` has no valid lexical representation.

Note: The numeric literals {IntValue} and {FloatValue} both restrict being
immediately followed by a letter (or other {NameStart}) to reduce confusion
or unexpected behavior since GraphQL only supports decimal numbers.


### Boolean Value
Expand Down