diff --git a/src/Core/Language.Tests/Language.Tests.csproj b/src/Core/Language.Tests/Language.Tests.csproj
index ea2f4ccade1..3bfa26fd210 100644
--- a/src/Core/Language.Tests/Language.Tests.csproj
+++ b/src/Core/Language.Tests/Language.Tests.csproj
@@ -5,6 +5,7 @@
$([System.IO.Path]::Combine($(ChilliCurrentDirectory), '..', '..', '..', 'tools'))
$([System.IO.Path]::Combine($(ChilliImport), 'CoreTestFramework.props'))
$([System.IO.Path]::Combine($(ChilliImport), 'TestSettings.props'))
+ true
diff --git a/src/Core/Language.Tests/Parser/SyntaxTokenInfo.cs b/src/Core/Language.Tests/Parser/SyntaxTokenInfo.cs
index a1729d60461..816d9697647 100644
--- a/src/Core/Language.Tests/Parser/SyntaxTokenInfo.cs
+++ b/src/Core/Language.Tests/Parser/SyntaxTokenInfo.cs
@@ -1,3 +1,6 @@
+using System;
+using System.Text;
+
namespace HotChocolate.Language
{
public sealed class SyntaxTokenInfo
@@ -7,13 +10,15 @@ public SyntaxTokenInfo(
int start,
int end,
int line,
- int column)
+ int column,
+ string value)
{
Kind = kind;
Start = start;
End = end;
Line = line;
Column = column;
+ Value = value;
}
///
@@ -43,15 +48,27 @@ public SyntaxTokenInfo(
///
public int Column { get; }
- public static SyntaxTokenInfo FromReader(
- in Utf8GraphQLReader reader)
+ public string Value { get; }
+
+ public unsafe static SyntaxTokenInfo FromReader(in Utf8GraphQLReader reader)
{
+ string value = null;
+
+ ReadOnlySpan token = reader.GraphQLData.Slice(
+ reader.Start, reader.End - reader.Start);
+
+ fixed (byte* b = token)
+ {
+ value = Encoding.UTF8.GetString(b, token.Length);
+ }
+
return new SyntaxTokenInfo(
reader.Kind,
reader.Start,
reader.End,
reader.Line,
- reader.Column);
+ reader.Column,
+ value);
}
}
}
diff --git a/src/Core/Language.Tests/Parser/Utf8ReaderTests.cs b/src/Core/Language.Tests/Parser/Utf8ReaderTests.cs
index 6a2091d9972..f3a1099cf44 100644
--- a/src/Core/Language.Tests/Parser/Utf8ReaderTests.cs
+++ b/src/Core/Language.Tests/Parser/Utf8ReaderTests.cs
@@ -12,21 +12,18 @@ public class Utf8ReaderTests
[Fact]
public void Read_Two_NameTokens()
{
- var source = new ReadOnlySpan(
- Encoding.UTF8.GetBytes("type foo"));
+ var source = new ReadOnlySpan(Encoding.UTF8.GetBytes("type foo"));
var lexer = new Utf8GraphQLReader(source);
Assert.Equal(TokenKind.StartOfFile, lexer.Kind);
Assert.True(lexer.Read());
Assert.Equal(TokenKind.Name, lexer.Kind);
- Assert.Equal("type",
- Encoding.UTF8.GetString(lexer.Value.ToArray()));
+ Assert.Equal("type", Encoding.UTF8.GetString(lexer.Value.ToArray()));
Assert.True(lexer.Read());
Assert.Equal(TokenKind.Name, lexer.Kind);
- Assert.Equal("foo",
- Encoding.UTF8.GetString(lexer.Value.ToArray()));
+ Assert.Equal("foo", Encoding.UTF8.GetString(lexer.Value.ToArray()));
Assert.False(lexer.Read());
Assert.Equal(TokenKind.EndOfFile, lexer.Kind);
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Id_As_Name.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Id_As_Name.snap
index 96154955c52..683c19f2d13 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Id_As_Name.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Id_As_Name.snap
@@ -42,7 +42,7 @@ subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" })
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache_Query.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache_Query.snap
index 96154955c52..683c19f2d13 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache_Query.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_AllProps_No_Cache_Query.snap
@@ -42,7 +42,7 @@ subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" })
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_No_Cache.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_No_Cache.snap
index 96154955c52..683c19f2d13 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_No_Cache.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_No_Cache.snap
@@ -42,7 +42,7 @@ subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" })
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_With_Cache.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_With_Cache.snap
index 96154955c52..683c19f2d13 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_With_Cache.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Kitchen_Sink_Query_With_Cache.snap
@@ -42,7 +42,7 @@ subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" })
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Skip_Custom_Property.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Skip_Custom_Property.snap
index 96154955c52..683c19f2d13 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Skip_Custom_Property.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8GraphQLRequestParserTests.Parse_Skip_Custom_Property.snap
@@ -42,7 +42,7 @@ subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" })
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery.snap
index 2bd37549ef8..95b710b1ae7 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery.snap
@@ -1420,7 +1420,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery_sdl.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery_sdl.snap
index 96154955c52..683c19f2d13 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery_sdl.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkQuery_sdl.snap
@@ -42,7 +42,7 @@ subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" })
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap
index fe863ce6b6c..89929dc5983 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema.snap
@@ -183,7 +183,7 @@
"Line": 17,
"Column": 3
},
- "Value": "This is a description of the `two` field.",
+ "Value": " This is a description of the `two` field.",
"Block": true
},
"Arguments": [
@@ -197,7 +197,7 @@
"Line": 21,
"Column": 5
},
- "Value": "This is a description of the `argument` argument.",
+ "Value": " This is a description of the `argument` argument.",
"Block": true
},
"Type": {
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema_sdl.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema_sdl.snap
index 1025ca9fbda..df39479dc8a 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema_sdl.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8KitchenSinkParserTests.ParseFacebookKitchenSinkSchema_sdl.snap
@@ -10,10 +10,10 @@ of the `Foo` type.
type Foo implements Bar & Baz {
one: Type
"""
- This is a description of the `two` field.
+ This is a description of the `two` field.
"""
two("""
- This is a description of the `argument` argument.
+ This is a description of the `argument` argument.
""" argument: InputType!): Type
three(argument: InputType other: String): Int
four(argument: String = "string"): String
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8QueryParserTests.KitchenSinkQueryQuery.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8QueryParserTests.KitchenSinkQueryQuery.snap
index 2bd37549ef8..95b710b1ae7 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8QueryParserTests.KitchenSinkQueryQuery.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8QueryParserTests.KitchenSinkQueryQuery.snap
@@ -1420,7 +1420,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap
index d94b072013f..f8a94675236 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockStringValue.snap
@@ -4,55 +4,63 @@
"Start": 0,
"End": 1,
"Line": 1,
- "Column": 1
+ "Column": 1,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 2,
"End": 4,
"Line": 1,
- "Column": 3
+ "Column": 3,
+ "Value": "me"
},
{
"Kind": "LeftParenthesis",
"Start": 4,
"End": 5,
"Line": 1,
- "Column": 5
+ "Column": 5,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 5,
"End": 6,
"Line": 1,
- "Column": 6
+ "Column": 6,
+ "Value": "a"
},
{
"Kind": "Colon",
"Start": 6,
"End": 7,
"Line": 1,
- "Column": 7
+ "Column": 7,
+ "Value": ":"
},
{
"Kind": "BlockString",
"Start": 8,
"End": 26,
"Line": 1,
- "Column": 9
+ "Column": 9,
+ "Value": "\"\"\"\n Abcdef\n\"\""
},
{
"Kind": "RightParenthesis",
"Start": 27,
"End": 28,
"Line": 3,
- "Column": 1
+ "Column": 1,
+ "Value": ")"
},
{
"Kind": "RightBrace",
"Start": 29,
"End": 30,
"Line": 3,
- "Column": 3
+ "Column": 3,
+ "Value": "}"
}
]
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockString_SkipEscapes.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockString_SkipEscapes.snap
index 5dcd0c34a73..fbfc47c421e 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockString_SkipEscapes.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_BlockString_SkipEscapes.snap
@@ -4,20 +4,23 @@
"Start": 0,
"End": 3,
"Line": 1,
- "Column": 1
+ "Column": 1,
+ "Value": "abc"
},
{
"Kind": "BlockString",
"Start": 4,
"End": 16,
"Line": 1,
- "Column": 5
+ "Column": 5,
+ "Value": "\"\"\"def\\\"\"\"\"\""
},
{
"Kind": "Name",
"Start": 18,
"End": 21,
"Line": 1,
- "Column": 19
+ "Column": 19,
+ "Value": "ghi"
}
]
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_Comment.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_Comment.snap
index 2b0af6b6925..9676aa9aa6b 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_Comment.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_Comment.snap
@@ -4,27 +4,31 @@
"Start": 0,
"End": 1,
"Line": 1,
- "Column": 1
+ "Column": 1,
+ "Value": "{"
},
{
"Kind": "Comment",
"Start": 2,
"End": 19,
"Line": 1,
- "Column": 3
+ "Column": 3,
+ "Value": "#test me foo bar "
},
{
"Kind": "Name",
"Start": 21,
"End": 23,
"Line": 2,
- "Column": 2
+ "Column": 2,
+ "Value": "me"
},
{
"Kind": "RightBrace",
"Start": 24,
"End": 25,
"Line": 2,
- "Column": 5
+ "Column": 5,
+ "Value": "}"
}
]
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_KitchenSinkQuery.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_KitchenSinkQuery.snap
index 9322872ea30..cee4c33397e 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_KitchenSinkQuery.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_KitchenSinkQuery.snap
@@ -4,1231 +4,1407 @@
"Start": 0,
"End": 44,
"Line": 1,
- "Column": 1
+ "Column": 1,
+ "Value": "# Copyright (c) 2015-present, Facebook, Inc."
},
{
"Kind": "Comment",
"Start": 45,
"End": 46,
"Line": 2,
- "Column": 1
+ "Column": 1,
+ "Value": "#"
},
{
"Kind": "Comment",
"Start": 47,
"End": 112,
"Line": 3,
- "Column": 1
+ "Column": 1,
+ "Value": "# This source code is licensed under the MIT license found in the"
},
{
"Kind": "Comment",
"Start": 113,
"End": 170,
"Line": 4,
- "Column": 1
+ "Column": 1,
+ "Value": "# LICENSE file in the root directory of this source tree."
},
{
"Kind": "Name",
"Start": 172,
"End": 177,
"Line": 6,
- "Column": 1
+ "Column": 1,
+ "Value": "query"
},
{
"Kind": "Name",
"Start": 178,
"End": 187,
"Line": 6,
- "Column": 7
+ "Column": 7,
+ "Value": "queryName"
},
{
"Kind": "LeftParenthesis",
"Start": 187,
"End": 188,
"Line": 6,
- "Column": 16
+ "Column": 16,
+ "Value": "("
},
{
"Kind": "Dollar",
"Start": 188,
"End": 189,
"Line": 6,
- "Column": 17
+ "Column": 17,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 189,
"End": 192,
"Line": 6,
- "Column": 18
+ "Column": 18,
+ "Value": "foo"
},
{
"Kind": "Colon",
"Start": 192,
"End": 193,
"Line": 6,
- "Column": 21
+ "Column": 21,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 194,
"End": 205,
"Line": 6,
- "Column": 23
+ "Column": 23,
+ "Value": "ComplexType"
},
{
"Kind": "Dollar",
"Start": 207,
"End": 208,
"Line": 6,
- "Column": 36
+ "Column": 36,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 208,
"End": 212,
"Line": 6,
- "Column": 37
+ "Column": 37,
+ "Value": "site"
},
{
"Kind": "Colon",
"Start": 212,
"End": 213,
"Line": 6,
- "Column": 41
+ "Column": 41,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 214,
"End": 218,
"Line": 6,
- "Column": 43
+ "Column": 43,
+ "Value": "Site"
},
{
"Kind": "Equal",
"Start": 219,
"End": 220,
"Line": 6,
- "Column": 48
+ "Column": 48,
+ "Value": "="
},
{
"Kind": "Name",
"Start": 221,
"End": 227,
"Line": 6,
- "Column": 50
+ "Column": 50,
+ "Value": "MOBILE"
},
{
"Kind": "RightParenthesis",
"Start": 227,
"End": 228,
"Line": 6,
- "Column": 56
+ "Column": 56,
+ "Value": ")"
},
{
"Kind": "LeftBrace",
"Start": 229,
"End": 230,
"Line": 6,
- "Column": 58
+ "Column": 58,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 233,
"End": 245,
"Line": 7,
- "Column": 3
+ "Column": 3,
+ "Value": "whoever123is"
},
{
"Kind": "Colon",
"Start": 245,
"End": 246,
"Line": 7,
- "Column": 15
+ "Column": 15,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 247,
"End": 251,
"Line": 7,
- "Column": 17
+ "Column": 17,
+ "Value": "node"
},
{
"Kind": "LeftParenthesis",
"Start": 251,
"End": 252,
"Line": 7,
- "Column": 21
+ "Column": 21,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 252,
"End": 254,
"Line": 7,
- "Column": 22
+ "Column": 22,
+ "Value": "id"
},
{
"Kind": "Colon",
"Start": 254,
"End": 255,
"Line": 7,
- "Column": 24
+ "Column": 24,
+ "Value": ":"
},
{
"Kind": "LeftBracket",
"Start": 256,
"End": 257,
"Line": 7,
- "Column": 26
+ "Column": 26,
+ "Value": "["
},
{
"Kind": "Integer",
"Start": 257,
"End": 260,
"Line": 7,
- "Column": 27
+ "Column": 27,
+ "Value": "123"
},
{
"Kind": "Integer",
"Start": 262,
"End": 265,
"Line": 7,
- "Column": 32
+ "Column": 32,
+ "Value": "456"
},
{
"Kind": "RightBracket",
"Start": 265,
"End": 266,
"Line": 7,
- "Column": 35
+ "Column": 35,
+ "Value": "]"
},
{
"Kind": "RightParenthesis",
"Start": 266,
"End": 267,
"Line": 7,
- "Column": 36
+ "Column": 36,
+ "Value": ")"
},
{
"Kind": "LeftBrace",
"Start": 268,
"End": 269,
"Line": 7,
- "Column": 38
+ "Column": 38,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 274,
"End": 276,
"Line": 8,
- "Column": 5
+ "Column": 5,
+ "Value": "id"
},
{
"Kind": "Spread",
"Start": 283,
"End": 286,
"Line": 9,
- "Column": 5
+ "Column": 5,
+ "Value": "..."
},
{
"Kind": "Name",
"Start": 287,
"End": 289,
"Line": 9,
- "Column": 9
+ "Column": 9,
+ "Value": "on"
},
{
"Kind": "Name",
"Start": 290,
"End": 294,
"Line": 9,
- "Column": 12
+ "Column": 12,
+ "Value": "User"
},
{
"Kind": "At",
"Start": 295,
"End": 296,
"Line": 9,
- "Column": 17
+ "Column": 17,
+ "Value": "@"
},
{
"Kind": "Name",
"Start": 296,
"End": 301,
"Line": 9,
- "Column": 18
+ "Column": 18,
+ "Value": "defer"
},
{
"Kind": "LeftBrace",
"Start": 302,
"End": 303,
"Line": 9,
- "Column": 24
+ "Column": 24,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 310,
"End": 316,
"Line": 10,
- "Column": 7
+ "Column": 7,
+ "Value": "field2"
},
{
"Kind": "LeftBrace",
"Start": 317,
"End": 318,
"Line": 10,
- "Column": 14
+ "Column": 14,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 327,
"End": 329,
"Line": 11,
- "Column": 9
+ "Column": 9,
+ "Value": "id"
},
{
"Kind": "Name",
"Start": 340,
"End": 345,
"Line": 12,
- "Column": 9
+ "Column": 9,
+ "Value": "alias"
},
{
"Kind": "Colon",
"Start": 345,
"End": 346,
"Line": 12,
- "Column": 14
+ "Column": 14,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 347,
"End": 353,
"Line": 12,
- "Column": 16
+ "Column": 16,
+ "Value": "field1"
},
{
"Kind": "LeftParenthesis",
"Start": 353,
"End": 354,
"Line": 12,
- "Column": 22
+ "Column": 22,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 354,
"End": 359,
"Line": 12,
- "Column": 23
+ "Column": 23,
+ "Value": "first"
},
{
"Kind": "Colon",
"Start": 359,
"End": 360,
"Line": 12,
- "Column": 28
+ "Column": 28,
+ "Value": ":"
},
{
"Kind": "Integer",
"Start": 360,
"End": 362,
"Line": 12,
- "Column": 29
+ "Column": 29,
+ "Value": "10"
},
{
"Kind": "Name",
"Start": 364,
"End": 369,
"Line": 12,
- "Column": 33
+ "Column": 33,
+ "Value": "after"
},
{
"Kind": "Colon",
"Start": 369,
"End": 370,
"Line": 12,
- "Column": 38
+ "Column": 38,
+ "Value": ":"
},
{
"Kind": "Dollar",
"Start": 370,
"End": 371,
"Line": 12,
- "Column": 39
+ "Column": 39,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 371,
"End": 374,
"Line": 12,
- "Column": 40
+ "Column": 40,
+ "Value": "foo"
},
{
"Kind": "RightParenthesis",
"Start": 375,
"End": 376,
"Line": 12,
- "Column": 44
+ "Column": 44,
+ "Value": ")"
},
{
"Kind": "At",
"Start": 377,
"End": 378,
"Line": 12,
- "Column": 46
+ "Column": 46,
+ "Value": "@"
},
{
"Kind": "Name",
"Start": 378,
"End": 385,
"Line": 12,
- "Column": 47
+ "Column": 47,
+ "Value": "include"
},
{
"Kind": "LeftParenthesis",
"Start": 385,
"End": 386,
"Line": 12,
- "Column": 54
+ "Column": 54,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 386,
"End": 388,
"Line": 12,
- "Column": 55
+ "Column": 55,
+ "Value": "if"
},
{
"Kind": "Colon",
"Start": 388,
"End": 389,
"Line": 12,
- "Column": 57
+ "Column": 57,
+ "Value": ":"
},
{
"Kind": "Dollar",
"Start": 390,
"End": 391,
"Line": 12,
- "Column": 59
+ "Column": 59,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 391,
"End": 394,
"Line": 12,
- "Column": 60
+ "Column": 60,
+ "Value": "foo"
},
{
"Kind": "RightParenthesis",
"Start": 394,
"End": 395,
"Line": 12,
- "Column": 63
+ "Column": 63,
+ "Value": ")"
},
{
"Kind": "LeftBrace",
"Start": 396,
"End": 397,
"Line": 12,
- "Column": 65
+ "Column": 65,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 408,
"End": 410,
"Line": 13,
- "Column": 11
+ "Column": 11,
+ "Value": "id"
},
{
"Kind": "Spread",
"Start": 422,
"End": 425,
"Line": 14,
- "Column": 11
+ "Column": 11,
+ "Value": "..."
},
{
"Kind": "Name",
"Start": 425,
"End": 429,
"Line": 14,
- "Column": 14
+ "Column": 14,
+ "Value": "frag"
},
{
"Kind": "RightBrace",
"Start": 438,
"End": 439,
"Line": 15,
- "Column": 9
+ "Column": 9,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 446,
"End": 447,
"Line": 16,
- "Column": 7
+ "Column": 7,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 452,
"End": 453,
"Line": 17,
- "Column": 5
+ "Column": 5,
+ "Value": "}"
},
{
"Kind": "Spread",
"Start": 458,
"End": 461,
"Line": 18,
- "Column": 5
+ "Column": 5,
+ "Value": "..."
},
{
"Kind": "At",
"Start": 462,
"End": 463,
"Line": 18,
- "Column": 9
+ "Column": 9,
+ "Value": "@"
},
{
"Kind": "Name",
"Start": 463,
"End": 467,
"Line": 18,
- "Column": 10
+ "Column": 10,
+ "Value": "skip"
},
{
"Kind": "LeftParenthesis",
"Start": 467,
"End": 468,
"Line": 18,
- "Column": 14
+ "Column": 14,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 468,
"End": 474,
"Line": 18,
- "Column": 15
+ "Column": 15,
+ "Value": "unless"
},
{
"Kind": "Colon",
"Start": 474,
"End": 475,
"Line": 18,
- "Column": 21
+ "Column": 21,
+ "Value": ":"
},
{
"Kind": "Dollar",
"Start": 476,
"End": 477,
"Line": 18,
- "Column": 23
+ "Column": 23,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 477,
"End": 480,
"Line": 18,
- "Column": 24
+ "Column": 24,
+ "Value": "foo"
},
{
"Kind": "RightParenthesis",
"Start": 480,
"End": 481,
"Line": 18,
- "Column": 27
+ "Column": 27,
+ "Value": ")"
},
{
"Kind": "LeftBrace",
"Start": 482,
"End": 483,
"Line": 18,
- "Column": 29
+ "Column": 29,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 490,
"End": 492,
"Line": 19,
- "Column": 7
+ "Column": 7,
+ "Value": "id"
},
{
"Kind": "RightBrace",
"Start": 497,
"End": 498,
"Line": 20,
- "Column": 5
+ "Column": 5,
+ "Value": "}"
},
{
"Kind": "Spread",
"Start": 503,
"End": 506,
"Line": 21,
- "Column": 5
+ "Column": 5,
+ "Value": "..."
},
{
"Kind": "LeftBrace",
"Start": 507,
"End": 508,
"Line": 21,
- "Column": 9
+ "Column": 9,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 515,
"End": 517,
"Line": 22,
- "Column": 7
+ "Column": 7,
+ "Value": "id"
},
{
"Kind": "RightBrace",
"Start": 522,
"End": 523,
"Line": 23,
- "Column": 5
+ "Column": 5,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 526,
"End": 527,
"Line": 24,
- "Column": 3
+ "Column": 3,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 528,
"End": 529,
"Line": 25,
- "Column": 1
+ "Column": 1,
+ "Value": "}"
},
{
"Kind": "Name",
"Start": 531,
"End": 539,
"Line": 27,
- "Column": 1
+ "Column": 1,
+ "Value": "mutation"
},
{
"Kind": "Name",
"Start": 540,
"End": 549,
"Line": 27,
- "Column": 10
+ "Column": 10,
+ "Value": "likeStory"
},
{
"Kind": "LeftBrace",
"Start": 550,
"End": 551,
"Line": 27,
- "Column": 20
+ "Column": 20,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 554,
"End": 558,
"Line": 28,
- "Column": 3
+ "Column": 3,
+ "Value": "like"
},
{
"Kind": "LeftParenthesis",
"Start": 558,
"End": 559,
"Line": 28,
- "Column": 7
+ "Column": 7,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 559,
"End": 564,
"Line": 28,
- "Column": 8
+ "Column": 8,
+ "Value": "story"
},
{
"Kind": "Colon",
"Start": 564,
"End": 565,
"Line": 28,
- "Column": 13
+ "Column": 13,
+ "Value": ":"
},
{
"Kind": "Integer",
"Start": 566,
"End": 569,
"Line": 28,
- "Column": 15
+ "Column": 15,
+ "Value": "123"
},
{
"Kind": "RightParenthesis",
"Start": 569,
"End": 570,
"Line": 28,
- "Column": 18
+ "Column": 18,
+ "Value": ")"
},
{
"Kind": "At",
"Start": 571,
"End": 572,
"Line": 28,
- "Column": 20
+ "Column": 20,
+ "Value": "@"
},
{
"Kind": "Name",
"Start": 572,
"End": 577,
"Line": 28,
- "Column": 21
+ "Column": 21,
+ "Value": "defer"
},
{
"Kind": "LeftBrace",
"Start": 578,
"End": 579,
"Line": 28,
- "Column": 27
+ "Column": 27,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 584,
"End": 589,
"Line": 29,
- "Column": 5
+ "Column": 5,
+ "Value": "story"
},
{
"Kind": "LeftBrace",
"Start": 590,
"End": 591,
"Line": 29,
- "Column": 11
+ "Column": 11,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 598,
"End": 600,
"Line": 30,
- "Column": 7
+ "Column": 7,
+ "Value": "id"
},
{
"Kind": "RightBrace",
"Start": 605,
"End": 606,
"Line": 31,
- "Column": 5
+ "Column": 5,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 609,
"End": 610,
"Line": 32,
- "Column": 3
+ "Column": 3,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 611,
"End": 612,
"Line": 33,
- "Column": 1
+ "Column": 1,
+ "Value": "}"
},
{
"Kind": "Name",
"Start": 614,
"End": 626,
"Line": 35,
- "Column": 1
+ "Column": 1,
+ "Value": "subscription"
},
{
"Kind": "Name",
"Start": 627,
"End": 648,
"Line": 35,
- "Column": 14
+ "Column": 14,
+ "Value": "StoryLikeSubscription"
},
{
"Kind": "LeftParenthesis",
"Start": 648,
"End": 649,
"Line": 35,
- "Column": 35
+ "Column": 35,
+ "Value": "("
},
{
"Kind": "Dollar",
"Start": 649,
"End": 650,
"Line": 35,
- "Column": 36
+ "Column": 36,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 650,
"End": 655,
"Line": 35,
- "Column": 37
+ "Column": 37,
+ "Value": "input"
},
{
"Kind": "Colon",
"Start": 655,
"End": 656,
"Line": 35,
- "Column": 42
+ "Column": 42,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 657,
"End": 680,
"Line": 35,
- "Column": 44
+ "Column": 44,
+ "Value": "StoryLikeSubscribeInput"
},
{
"Kind": "RightParenthesis",
"Start": 680,
"End": 681,
"Line": 35,
- "Column": 67
+ "Column": 67,
+ "Value": ")"
},
{
"Kind": "LeftBrace",
"Start": 682,
"End": 683,
"Line": 35,
- "Column": 69
+ "Column": 69,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 686,
"End": 704,
"Line": 36,
- "Column": 3
+ "Column": 3,
+ "Value": "storyLikeSubscribe"
},
{
"Kind": "LeftParenthesis",
"Start": 704,
"End": 705,
"Line": 36,
- "Column": 21
+ "Column": 21,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 705,
"End": 710,
"Line": 36,
- "Column": 22
+ "Column": 22,
+ "Value": "input"
},
{
"Kind": "Colon",
"Start": 710,
"End": 711,
"Line": 36,
- "Column": 27
+ "Column": 27,
+ "Value": ":"
},
{
"Kind": "Dollar",
"Start": 712,
"End": 713,
"Line": 36,
- "Column": 29
+ "Column": 29,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 713,
"End": 718,
"Line": 36,
- "Column": 30
+ "Column": 30,
+ "Value": "input"
},
{
"Kind": "RightParenthesis",
"Start": 718,
"End": 719,
"Line": 36,
- "Column": 35
+ "Column": 35,
+ "Value": ")"
},
{
"Kind": "LeftBrace",
"Start": 720,
"End": 721,
"Line": 36,
- "Column": 37
+ "Column": 37,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 726,
"End": 731,
"Line": 37,
- "Column": 5
+ "Column": 5,
+ "Value": "story"
},
{
"Kind": "LeftBrace",
"Start": 732,
"End": 733,
"Line": 37,
- "Column": 11
+ "Column": 11,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 740,
"End": 746,
"Line": 38,
- "Column": 7
+ "Column": 7,
+ "Value": "likers"
},
{
"Kind": "LeftBrace",
"Start": 747,
"End": 748,
"Line": 38,
- "Column": 14
+ "Column": 14,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 757,
"End": 762,
"Line": 39,
- "Column": 9
+ "Column": 9,
+ "Value": "count"
},
{
"Kind": "RightBrace",
"Start": 769,
"End": 770,
"Line": 40,
- "Column": 7
+ "Column": 7,
+ "Value": "}"
},
{
"Kind": "Name",
"Start": 777,
"End": 789,
"Line": 41,
- "Column": 7
+ "Column": 7,
+ "Value": "likeSentence"
},
{
"Kind": "LeftBrace",
"Start": 790,
"End": 791,
"Line": 41,
- "Column": 20
+ "Column": 20,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 800,
"End": 804,
"Line": 42,
- "Column": 9
+ "Column": 9,
+ "Value": "text"
},
{
"Kind": "RightBrace",
"Start": 811,
"End": 812,
"Line": 43,
- "Column": 7
+ "Column": 7,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 817,
"End": 818,
"Line": 44,
- "Column": 5
+ "Column": 5,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 821,
"End": 822,
"Line": 45,
- "Column": 3
+ "Column": 3,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 823,
"End": 824,
"Line": 46,
- "Column": 1
+ "Column": 1,
+ "Value": "}"
},
{
"Kind": "Name",
"Start": 826,
"End": 834,
"Line": 48,
- "Column": 1
+ "Column": 1,
+ "Value": "fragment"
},
{
"Kind": "Name",
"Start": 835,
"End": 839,
"Line": 48,
- "Column": 10
+ "Column": 10,
+ "Value": "frag"
},
{
"Kind": "Name",
"Start": 840,
"End": 842,
"Line": 48,
- "Column": 15
+ "Column": 15,
+ "Value": "on"
},
{
"Kind": "Name",
"Start": 843,
"End": 849,
"Line": 48,
- "Column": 18
+ "Column": 18,
+ "Value": "Friend"
},
{
"Kind": "LeftBrace",
"Start": 850,
"End": 851,
"Line": 48,
- "Column": 25
+ "Column": 25,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 854,
"End": 857,
"Line": 49,
- "Column": 3
+ "Column": 3,
+ "Value": "foo"
},
{
"Kind": "LeftParenthesis",
"Start": 857,
"End": 858,
"Line": 49,
- "Column": 6
+ "Column": 6,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 858,
"End": 862,
"Line": 49,
- "Column": 7
+ "Column": 7,
+ "Value": "size"
},
{
"Kind": "Colon",
"Start": 862,
"End": 863,
"Line": 49,
- "Column": 11
+ "Column": 11,
+ "Value": ":"
},
{
"Kind": "Dollar",
"Start": 864,
"End": 865,
"Line": 49,
- "Column": 13
+ "Column": 13,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 865,
"End": 869,
"Line": 49,
- "Column": 14
+ "Column": 14,
+ "Value": "size"
},
{
"Kind": "Name",
"Start": 871,
"End": 874,
"Line": 49,
- "Column": 20
+ "Column": 20,
+ "Value": "bar"
},
{
"Kind": "Colon",
"Start": 874,
"End": 875,
"Line": 49,
- "Column": 23
+ "Column": 23,
+ "Value": ":"
},
{
"Kind": "Dollar",
"Start": 876,
"End": 877,
"Line": 49,
- "Column": 25
+ "Column": 25,
+ "Value": "$"
},
{
"Kind": "Name",
"Start": 877,
"End": 878,
"Line": 49,
- "Column": 26
+ "Column": 26,
+ "Value": "b"
},
{
"Kind": "Name",
"Start": 880,
"End": 883,
"Line": 49,
- "Column": 29
+ "Column": 29,
+ "Value": "obj"
},
{
"Kind": "Colon",
"Start": 883,
"End": 884,
"Line": 49,
- "Column": 32
+ "Column": 32,
+ "Value": ":"
},
{
"Kind": "LeftBrace",
"Start": 885,
"End": 886,
"Line": 49,
- "Column": 34
+ "Column": 34,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 886,
"End": 889,
"Line": 49,
- "Column": 35
+ "Column": 35,
+ "Value": "key"
},
{
"Kind": "Colon",
"Start": 889,
"End": 890,
"Line": 49,
- "Column": 38
+ "Column": 38,
+ "Value": ":"
},
{
"Kind": "String",
"Start": 891,
"End": 897,
"Line": 49,
- "Column": 40
+ "Column": 40,
+ "Value": "\"value"
},
{
"Kind": "Name",
"Start": 900,
"End": 905,
"Line": 49,
- "Column": 49
+ "Column": 49,
+ "Value": "block"
},
{
"Kind": "Colon",
"Start": 905,
"End": 906,
"Line": 49,
- "Column": 54
+ "Column": 54,
+ "Value": ":"
},
{
"Kind": "BlockString",
"Start": 907,
"End": 946,
"Line": 49,
- "Column": 56
+ "Column": 56,
+ "Value": "\"\"\"\n\n block string uses \\\"\"\"\n\n \"\""
},
{
"Kind": "RightBrace",
"Start": 947,
"End": 948,
"Line": 53,
- "Column": 1
+ "Column": 1,
+ "Value": "}"
},
{
"Kind": "RightParenthesis",
"Start": 948,
"End": 949,
"Line": 53,
- "Column": 2
+ "Column": 2,
+ "Value": ")"
},
{
"Kind": "RightBrace",
"Start": 950,
"End": 951,
"Line": 54,
- "Column": 1
+ "Column": 1,
+ "Value": "}"
},
{
"Kind": "LeftBrace",
"Start": 953,
"End": 954,
"Line": 56,
- "Column": 1
+ "Column": 1,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 957,
"End": 964,
"Line": 57,
- "Column": 3
+ "Column": 3,
+ "Value": "unnamed"
},
{
"Kind": "LeftParenthesis",
"Start": 964,
"End": 965,
"Line": 57,
- "Column": 10
+ "Column": 10,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 965,
"End": 971,
"Line": 57,
- "Column": 11
+ "Column": 11,
+ "Value": "truthy"
},
{
"Kind": "Colon",
"Start": 971,
"End": 972,
"Line": 57,
- "Column": 17
+ "Column": 17,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 973,
"End": 977,
"Line": 57,
- "Column": 19
+ "Column": 19,
+ "Value": "true"
},
{
"Kind": "Name",
"Start": 979,
"End": 985,
"Line": 57,
- "Column": 25
+ "Column": 25,
+ "Value": "falsey"
},
{
"Kind": "Colon",
"Start": 985,
"End": 986,
"Line": 57,
- "Column": 31
+ "Column": 31,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 987,
"End": 992,
"Line": 57,
- "Column": 33
+ "Column": 33,
+ "Value": "false"
},
{
"Kind": "Name",
"Start": 994,
"End": 1001,
"Line": 57,
- "Column": 40
+ "Column": 40,
+ "Value": "nullish"
},
{
"Kind": "Colon",
"Start": 1001,
"End": 1002,
"Line": 57,
- "Column": 47
+ "Column": 47,
+ "Value": ":"
},
{
"Kind": "Name",
"Start": 1003,
"End": 1007,
"Line": 57,
- "Column": 49
+ "Column": 49,
+ "Value": "null"
},
{
"Kind": "RightParenthesis",
"Start": 1007,
"End": 1008,
"Line": 57,
- "Column": 53
+ "Column": 53,
+ "Value": ")"
},
{
"Kind": "Name",
"Start": 1012,
"End": 1017,
"Line": 58,
- "Column": 3
+ "Column": 3,
+ "Value": "query"
},
{
"Kind": "RightBrace",
"Start": 1018,
"End": 1019,
"Line": 59,
- "Column": 1
+ "Column": 1,
+ "Value": "}"
}
]
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_NameBraceTokens.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_NameBraceTokens.snap
index 101f2e66710..5a9290f4318 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_NameBraceTokens.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_NameBraceTokens.snap
@@ -4,41 +4,47 @@
"Start": 0,
"End": 1,
"Line": 1,
- "Column": 1
+ "Column": 1,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 2,
"End": 3,
"Line": 1,
- "Column": 3
+ "Column": 3,
+ "Value": "x"
},
{
"Kind": "LeftBrace",
"Start": 4,
"End": 5,
"Line": 1,
- "Column": 5
+ "Column": 5,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 6,
"End": 7,
"Line": 1,
- "Column": 7
+ "Column": 7,
+ "Value": "y"
},
{
"Kind": "RightBrace",
"Start": 8,
"End": 9,
"Line": 1,
- "Column": 9
+ "Column": 9,
+ "Value": "}"
},
{
"Kind": "RightBrace",
"Start": 10,
"End": 11,
"Line": 1,
- "Column": 11
+ "Column": 11,
+ "Value": "}"
}
]
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_StringValue.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_StringValue.snap
index 663076819bc..306ac19b6d9 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_StringValue.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_StringValue.snap
@@ -4,55 +4,63 @@
"Start": 0,
"End": 1,
"Line": 1,
- "Column": 1
+ "Column": 1,
+ "Value": "{"
},
{
"Kind": "Name",
"Start": 2,
"End": 4,
"Line": 1,
- "Column": 3
+ "Column": 3,
+ "Value": "me"
},
{
"Kind": "LeftParenthesis",
"Start": 4,
"End": 5,
"Line": 1,
- "Column": 5
+ "Column": 5,
+ "Value": "("
},
{
"Kind": "Name",
"Start": 5,
"End": 6,
"Line": 1,
- "Column": 6
+ "Column": 6,
+ "Value": "a"
},
{
"Kind": "Colon",
"Start": 6,
"End": 7,
"Line": 1,
- "Column": 7
+ "Column": 7,
+ "Value": ":"
},
{
"Kind": "String",
"Start": 8,
"End": 19,
"Line": 1,
- "Column": 9
+ "Column": 9,
+ "Value": "\"Abc¢def\\n"
},
{
"Kind": "RightParenthesis",
"Start": 20,
"End": 21,
"Line": 1,
- "Column": 21
+ "Column": 21,
+ "Value": ")"
},
{
"Kind": "RightBrace",
"Start": 22,
"End": 23,
"Line": 1,
- "Column": 23
+ "Column": 23,
+ "Value": "}"
}
]
diff --git a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_String_SkipEscapes.snap b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_String_SkipEscapes.snap
index 14ffa51d9c9..7ef6cf6845a 100644
--- a/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_String_SkipEscapes.snap
+++ b/src/Core/Language.Tests/Parser/__snapshots__/Utf8ReaderTests.Read_String_SkipEscapes.snap
@@ -4,20 +4,23 @@
"Start": 0,
"End": 3,
"Line": 1,
- "Column": 1
+ "Column": 1,
+ "Value": "abc"
},
{
"Kind": "String",
"Start": 4,
"End": 10,
"Line": 1,
- "Column": 5
+ "Column": 5,
+ "Value": "\"def\\\""
},
{
"Kind": "Name",
"Start": 12,
"End": 15,
"Line": 1,
- "Column": 13
+ "Column": 13,
+ "Value": "ghi"
}
]
diff --git a/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithIndentation_OutputIsFormatted.snap b/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithIndentation_OutputIsFormatted.snap
index 96154955c52..683c19f2d13 100644
--- a/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithIndentation_OutputIsFormatted.snap
+++ b/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithIndentation_OutputIsFormatted.snap
@@ -42,7 +42,7 @@ subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) {
fragment frag on Friend {
foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" })
}
diff --git a/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithoutIndentation_OutputIsOneLine.snap b/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithoutIndentation_OutputIsOneLine.snap
index fd7e95795e2..e305793d923 100644
--- a/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithoutIndentation_OutputIsOneLine.snap
+++ b/src/Core/Language.Tests/Visitors/__snapshots__/QuerySyntaxSerializerTests.Serialize_KitchenSinkWithoutIndentation_OutputIsOneLine.snap
@@ -1,3 +1,3 @@
query queryName($foo: ComplexType, $site: Site = MOBILE) { whoever123is: node(id: [ 123, 456 ]) { id ... on User @defer { field2 { id alias: field1(first: 10, after: $foo) @include(if: $foo) { id ... frag } } } ... @skip(unless: $foo) { id } ... { id } } } mutation likeStory { like(story: 123) @defer { story { id } } } subscription StoryLikeSubscription($input: StoryLikeSubscribeInput) { storyLikeSubscribe(input: $input) { story { likers { count } likeSentence { text } } } } fragment frag on Friend { foo(size: $size, bar: $b, obj: { key: "value", block: """
- block string uses \"""
+ block string uses \"""
""" }) } { unnamed(truthy: true, falsey: false, nullish: null) query }
diff --git a/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Query.snap b/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Query.snap
index 5bb3694ac40..2a4a41e661b 100644
--- a/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Query.snap
+++ b/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Query.snap
@@ -1421,7 +1421,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
@@ -9422,7 +9422,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
@@ -9643,7 +9643,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
@@ -9837,7 +9837,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
@@ -10105,7 +10105,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
@@ -10177,7 +10177,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
}
@@ -10260,7 +10260,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
}
},
@@ -10272,7 +10272,7 @@
"Line": 49,
"Column": 56
},
- "Value": " block string uses \"\"\"",
+ "Value": " block string uses \"\"\"",
"Block": true
},
{
diff --git a/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Schema.snap b/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Schema.snap
index 81deec83754..450ef4cae60 100644
--- a/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Schema.snap
+++ b/src/Core/Language.Tests/__snapshots__/SyntaxNodeVisitorTests.Visit_Kitchen_Sink_Schema.snap
@@ -184,7 +184,7 @@
"Line": 17,
"Column": 3
},
- "Value": "This is a description of the `two` field.",
+ "Value": " This is a description of the `two` field.",
"Block": true
},
"Arguments": [
@@ -198,7 +198,7 @@
"Line": 21,
"Column": 5
},
- "Value": "This is a description of the `argument` argument.",
+ "Value": " This is a description of the `argument` argument.",
"Block": true
},
"Type": {
@@ -3686,7 +3686,7 @@
"Line": 17,
"Column": 3
},
- "Value": "This is a description of the `two` field.",
+ "Value": " This is a description of the `two` field.",
"Block": true
},
"Arguments": [
@@ -3700,7 +3700,7 @@
"Line": 21,
"Column": 5
},
- "Value": "This is a description of the `argument` argument.",
+ "Value": " This is a description of the `argument` argument.",
"Block": true
},
"Type": {
@@ -4453,7 +4453,7 @@
"Line": 17,
"Column": 3
},
- "Value": "This is a description of the `two` field.",
+ "Value": " This is a description of the `two` field.",
"Block": true
},
"Arguments": [
@@ -4467,7 +4467,7 @@
"Line": 21,
"Column": 5
},
- "Value": "This is a description of the `argument` argument.",
+ "Value": " This is a description of the `argument` argument.",
"Block": true
},
"Type": {
@@ -4594,7 +4594,7 @@
"Line": 21,
"Column": 5
},
- "Value": "This is a description of the `argument` argument.",
+ "Value": " This is a description of the `argument` argument.",
"Block": true
},
"Type": {
@@ -4719,7 +4719,7 @@
"Line": 21,
"Column": 5
},
- "Value": "This is a description of the `argument` argument.",
+ "Value": " This is a description of the `argument` argument.",
"Block": true
},
{
@@ -4740,7 +4740,7 @@
"Line": 17,
"Column": 3
},
- "Value": "This is a description of the `two` field.",
+ "Value": " This is a description of the `two` field.",
"Block": true
},
{
diff --git a/src/Core/Language/Parser/Utf8GraphQLReader.Constants.cs b/src/Core/Language/Parser/Utf8GraphQLReader.Constants.cs
new file mode 100644
index 00000000000..14696569356
--- /dev/null
+++ b/src/Core/Language/Parser/Utf8GraphQLReader.Constants.cs
@@ -0,0 +1,226 @@
+namespace HotChocolate.Language
+{
+ public ref partial struct Utf8GraphQLReader
+ {
+ private static readonly bool[] _isControlCharacter = new bool[char.MaxValue + 1];
+ private static readonly bool[] _isLetterOrUnderscore = new bool[256];
+ private static readonly bool[] _isLetterOrDigitOrUnderscore = new bool[256];
+ private static readonly bool[] _isEscapeCharacter = new bool[256];
+ private static readonly bool[] _isPunctuator = new bool[256];
+ private static readonly bool[] _isDigitOrMinus = new bool[256];
+ private static readonly bool[] _isDigit = new bool[256];
+ private static readonly byte[] _escapeCharacters = new byte[256];
+ private static readonly bool[] _trimComment = new bool[256];
+ private static readonly TokenKind[] _punctuatorKind = new TokenKind[256];
+ private static readonly bool[] _isControlCharacterNoNewLine = new bool[256];
+
+ public const byte A = (byte)'a';
+ public const byte Z = (byte)'z';
+ public const byte Hyphen = (byte)'-';
+ public const byte Underscore = (byte)'_';
+ public const byte Plus = (byte)'+';
+ public const byte Minus = (byte)'-';
+ public const byte Backslash = (byte)'\\';
+ public const byte Forwardslash = (byte)'/';
+ public const byte B = (byte)'b';
+ public const byte Backspace = (byte)'\b';
+ public const byte F = (byte)'f';
+ public const byte Formfeed = (byte)'\f';
+ public const byte N = (byte)'n';
+ public const byte R = (byte)'r';
+ public const byte T = (byte)'t';
+ public const byte Bang = (byte)'!';
+ public const byte Dollar = (byte)'$';
+ public const byte Ampersand = (byte)'&';
+ public const byte LeftParenthesis = (byte)'(';
+ public const byte RightParenthesis = (byte)')';
+ public const byte Colon = (byte)':';
+ public const byte Equal = (byte)'=';
+ public const byte At = (byte)'@';
+ public const byte LeftBracket = (byte)'[';
+ public const byte RightBracket = (byte)']';
+ public const byte LeftBrace = (byte)'{';
+ public const byte RightBrace = (byte)'}';
+ public const byte Pipe = (byte)'|';
+ public const byte Dot = (byte)'.';
+ public const byte Space = (byte)' ';
+ public const byte Hash = (byte)'#';
+ public const byte Tab = (byte)'\t';
+ public const byte U = (byte)'u';
+ public const byte Zero = (byte)'0';
+ public const byte E = (byte)'e';
+ public const byte NewLine = (byte)'\n';
+ public const byte Return = (byte)'\r';
+ public const byte Quote = (byte)'"';
+ public const byte Comma = (byte)',';
+
+ static Utf8GraphQLReader()
+ {
+ InitializeIsControlCharacterCache();
+ InitializeIsEscapeCharacterCache();
+ InitializeEscapeCharacterCache();
+ InitializeIsPunctuatorCache();
+ InitializeIsLetterOrUnderscoreCache();
+ InitializeIsLetterOrDigitOUnderscoreCache();
+ InitializeIsDigitCache();
+ InitializeIsDigitOrMinusCache();
+ InitializeTrimComment();
+ InitializePunctuator();
+ }
+
+ private static void InitializeIsControlCharacterCache()
+ {
+ for (int i = 0; i <= 31; i++)
+ {
+ _isControlCharacterNoNewLine[i] = true;
+ _isControlCharacter[i] = true;
+ }
+
+ _isControlCharacterNoNewLine[127] = true;
+ _isControlCharacter[127] = true;
+
+ _isControlCharacterNoNewLine[Tab] = false;
+ _isControlCharacterNoNewLine[Return] = false;
+ _isControlCharacterNoNewLine[NewLine] = false;
+ }
+
+ private static void InitializeIsEscapeCharacterCache()
+ {
+ _isEscapeCharacter[Quote] = true;
+ _isEscapeCharacter[Forwardslash] = true;
+ _isEscapeCharacter[Backslash] = true;
+ _isEscapeCharacter[B] = true;
+ _isEscapeCharacter[F] = true;
+ _isEscapeCharacter[N] = true;
+ _isEscapeCharacter[R] = true;
+ _isEscapeCharacter[T] = true;
+ _isEscapeCharacter[U] = true;
+ }
+
+ private static void InitializeEscapeCharacterCache()
+ {
+ for (int i = byte.MinValue; i <= byte.MaxValue; i++)
+ {
+ _escapeCharacters[i] = (byte)i;
+ }
+
+ _escapeCharacters[B] = Backspace;
+ _escapeCharacters[F] = Formfeed;
+ _escapeCharacters[N] = NewLine;
+ _escapeCharacters[R] = Return;
+ _escapeCharacters[T] = Tab;
+ }
+
+ private static void InitializeIsPunctuatorCache()
+ {
+ _isPunctuator['!'] = true;
+ _isPunctuator['$'] = true;
+ _isPunctuator['&'] = true;
+ _isPunctuator['('] = true;
+ _isPunctuator[')'] = true;
+ _isPunctuator[':'] = true;
+ _isPunctuator['='] = true;
+ _isPunctuator['@'] = true;
+ _isPunctuator['['] = true;
+ _isPunctuator[']'] = true;
+ _isPunctuator['{'] = true;
+ _isPunctuator['|'] = true;
+ _isPunctuator['}'] = true;
+ _isPunctuator['.'] = true;
+ }
+
+ private static void InitializeIsLetterOrUnderscoreCache()
+ {
+ for (char c = 'a'; c <= 'z'; c++)
+ {
+ _isLetterOrUnderscore[c] = true;
+ }
+
+ for (char c = 'A'; c <= 'Z'; c++)
+ {
+ _isLetterOrUnderscore[c] = true;
+ }
+
+ _isLetterOrUnderscore['_'] = true;
+ }
+
+ private static void InitializeIsLetterOrDigitOUnderscoreCache()
+ {
+ for (char c = 'a'; c <= 'z'; c++)
+ {
+ _isLetterOrDigitOrUnderscore[c] = true;
+ }
+
+ for (char c = 'A'; c <= 'Z'; c++)
+ {
+ _isLetterOrDigitOrUnderscore[c] = true;
+ }
+
+ _isLetterOrDigitOrUnderscore['0'] = true;
+ _isLetterOrDigitOrUnderscore['1'] = true;
+ _isLetterOrDigitOrUnderscore['2'] = true;
+ _isLetterOrDigitOrUnderscore['3'] = true;
+ _isLetterOrDigitOrUnderscore['4'] = true;
+ _isLetterOrDigitOrUnderscore['5'] = true;
+ _isLetterOrDigitOrUnderscore['6'] = true;
+ _isLetterOrDigitOrUnderscore['7'] = true;
+ _isLetterOrDigitOrUnderscore['8'] = true;
+ _isLetterOrDigitOrUnderscore['9'] = true;
+
+ _isLetterOrDigitOrUnderscore['_'] = true;
+ }
+
+ private static void InitializeIsDigitOrMinusCache()
+ {
+ _isDigitOrMinus['-'] = true;
+ _isDigitOrMinus['0'] = true;
+ _isDigitOrMinus['1'] = true;
+ _isDigitOrMinus['2'] = true;
+ _isDigitOrMinus['3'] = true;
+ _isDigitOrMinus['4'] = true;
+ _isDigitOrMinus['5'] = true;
+ _isDigitOrMinus['6'] = true;
+ _isDigitOrMinus['7'] = true;
+ _isDigitOrMinus['8'] = true;
+ _isDigitOrMinus['9'] = true;
+ }
+
+ private static void InitializeIsDigitCache()
+ {
+ _isDigit['0'] = true;
+ _isDigit['1'] = true;
+ _isDigit['2'] = true;
+ _isDigit['3'] = true;
+ _isDigit['4'] = true;
+ _isDigit['5'] = true;
+ _isDigit['6'] = true;
+ _isDigit['7'] = true;
+ _isDigit['8'] = true;
+ _isDigit['9'] = true;
+ }
+
+ private static void InitializeTrimComment()
+ {
+ _trimComment[GraphQLConstants.Hash] = true;
+ _trimComment[GraphQLConstants.Space] = true;
+ _trimComment[GraphQLConstants.Tab] = true;
+ }
+
+ private static void InitializePunctuator()
+ {
+ _punctuatorKind[GraphQLConstants.Bang] = TokenKind.Bang;
+ _punctuatorKind[GraphQLConstants.Dollar] = TokenKind.Dollar;
+ _punctuatorKind[GraphQLConstants.Ampersand] = TokenKind.Ampersand;
+ _punctuatorKind[GraphQLConstants.LeftParenthesis] = TokenKind.LeftParenthesis;
+ _punctuatorKind[GraphQLConstants.RightParenthesis] = TokenKind.RightParenthesis;
+ _punctuatorKind[GraphQLConstants.Colon] = TokenKind.Colon;
+ _punctuatorKind[GraphQLConstants.Equal] = TokenKind.Equal;
+ _punctuatorKind[GraphQLConstants.At] = TokenKind.At;
+ _punctuatorKind[GraphQLConstants.LeftBracket] = TokenKind.LeftBracket;
+ _punctuatorKind[GraphQLConstants.RightBracket] = TokenKind.RightBracket;
+ _punctuatorKind[GraphQLConstants.LeftBrace] = TokenKind.LeftBrace;
+ _punctuatorKind[GraphQLConstants.RightBrace] = TokenKind.RightBrace;
+ _punctuatorKind[GraphQLConstants.Pipe] = TokenKind.Pipe;
+ }
+ }
+}
diff --git a/src/Core/Language/Parser/Utf8GraphQLReader.cs b/src/Core/Language/Parser/Utf8GraphQLReader.cs
index 295d9faa591..9185d0bb5ea 100644
--- a/src/Core/Language/Parser/Utf8GraphQLReader.cs
+++ b/src/Core/Language/Parser/Utf8GraphQLReader.cs
@@ -111,35 +111,35 @@ public bool Read()
byte code = _graphQLData[_position];
- if (GraphQLConstants.IsPunctuator(code))
+ if (_isPunctuator[code])
{
ReadPunctuatorToken(code);
return true;
}
- if (GraphQLConstants.IsLetterOrUnderscore(code))
+ if (_isLetterOrUnderscore[code])
{
ReadNameToken();
return true;
}
- if (GraphQLConstants.IsDigitOrMinus(code))
+ if (_isDigitOrMinus[code])
{
ReadNumberToken(code);
return true;
}
- if (code == GraphQLConstants.Hash)
+ if (code == Hash)
{
ReadCommentToken();
return true;
}
- if (code == GraphQLConstants.Quote)
+ if (code == Quote)
{
if (_length > _position + 2
- && _graphQLData[_position + 1] == GraphQLConstants.Quote
- && _graphQLData[_position + 2] == GraphQLConstants.Quote)
+ && _graphQLData[_position + 1] == Quote
+ && _graphQLData[_position + 2] == Quote)
{
_position += 2;
ReadBlockStringToken();
@@ -173,8 +173,7 @@ private void ReadNameToken()
var position = _position;
while (++position < _length
- && GraphQLConstants.IsLetterOrDigitOrUnderscore(
- _graphQLData[position]))
+ && _isLetterOrDigitOrUnderscore[_graphQLData[position]])
{
}
@@ -189,7 +188,7 @@ private void ReadNameToken()
/// Reads punctuator tokens as specified in
/// http://facebook.github.io/graphql/October2016/#sec-Punctuators
/// one of ! $ ( ) ... : = @ [ ] { | }
- /// additionaly the reader will tokenize ampersands.
+ /// additionally the reader will tokenize ampersands.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ReadPunctuatorToken(byte code)
@@ -198,10 +197,10 @@ private void ReadPunctuatorToken(byte code)
_end = ++_position;
_value = null;
- if (code == GraphQLConstants.Dot)
+ if (code == Dot)
{
- if (_graphQLData[_position] == GraphQLConstants.Dot
- && _graphQLData[_position + 1] == GraphQLConstants.Dot)
+ if (_graphQLData[_position] == Dot
+ && _graphQLData[_position + 1] == Dot)
{
_position += 2;
_end = _position;
@@ -218,7 +217,7 @@ private void ReadPunctuatorToken(byte code)
}
else
{
- _kind = GraphQLConstants.PunctuatorKind(code);
+ _kind = _punctuatorKind[code];
}
}
@@ -236,15 +235,15 @@ private void ReadNumberToken(byte firstCode)
byte code = firstCode;
var isFloat = false;
- if (code == GraphQLConstants.Minus)
+ if (code == Minus)
{
code = _graphQLData[++_position];
}
- if (code == GraphQLConstants.Zero && !IsEndOfStream(_position + 1))
+ if (code == Zero && !IsEndOfStream(_position + 1))
{
code = _graphQLData[++_position];
- if (GraphQLConstants.IsDigit(code))
+ if (_isDigit[code])
{
throw new SyntaxException(this,
"Invalid number, unexpected digit after 0: " +
@@ -256,7 +255,7 @@ private void ReadNumberToken(byte firstCode)
code = ReadDigits(code);
}
- if (code == GraphQLConstants.Dot)
+ if (code == Dot)
{
isFloat = true;
_floatFormat = Language.FloatFormat.FixedPoint;
@@ -264,13 +263,13 @@ private void ReadNumberToken(byte firstCode)
code = ReadDigits(code);
}
- if ((code | 0x20) == GraphQLConstants.E)
+ if ((code | 0x20) == E)
{
isFloat = true;
_floatFormat = Language.FloatFormat.Exponential;
code = _graphQLData[++_position];
- if (code == GraphQLConstants.Plus
- || code == GraphQLConstants.Minus)
+ if (code == Plus
+ || code == Minus)
{
code = _graphQLData[++_position];
}
@@ -286,7 +285,7 @@ private void ReadNumberToken(byte firstCode)
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private byte ReadDigits(byte firstCode)
{
- if (!GraphQLConstants.IsDigit(firstCode))
+ if (!_isDigit[firstCode])
{
throw new SyntaxException(this,
"Invalid number, expected digit but got: " +
@@ -299,12 +298,12 @@ private byte ReadDigits(byte firstCode)
{
if (++_position >= _length)
{
- code = GraphQLConstants.Space;
+ code = Space;
break;
}
code = _graphQLData[_position];
- if (!GraphQLConstants.IsDigit(code))
+ if (!_isDigit[code])
{
break;
}
@@ -324,63 +323,27 @@ private void ReadCommentToken()
{
var start = _position;
var trimStart = _position + 1;
- bool trim = true;
- bool run = true;
+ var trim = true;
+ var run = true;
while (run && ++_position < _length)
{
- byte code = _graphQLData[_position];
+ var code = _graphQLData[_position];
- switch (code)
+ if (code == Hash || code == Space || code == Tab)
{
- // SourceCharacter
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case GraphQLConstants.NewLine:
- case 11:
- case 12:
- case GraphQLConstants.Return:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- case 127:
- run = false;
- break;
-
- case GraphQLConstants.Hash:
- case GraphQLConstants.Space:
- case GraphQLConstants.Tab:
- if (trim)
- {
- trimStart = _position;
- }
- break;
-
- default:
- trim = false;
- break;
+ if (trim)
+ {
+ trimStart = _position;
+ }
+ }
+ else if (_isControlCharacter[code])
+ {
+ run = false;
+ }
+ else
+ {
+ trim = false;
}
}
@@ -405,65 +368,32 @@ private void ReadStringValueToken()
{
byte code = _graphQLData[_position];
- switch (code)
+ if (code == NewLine || code == Return)
{
- case GraphQLConstants.NewLine:
- case GraphQLConstants.Return:
- return;
-
- // closing Quote (")
- case GraphQLConstants.Quote:
- _kind = TokenKind.String;
- _start = start;
- _end = _position;
- _value = _graphQLData.Slice(
- start + 1,
- _position - start - 1);
- _position++;
- return;
-
- case GraphQLConstants.Backslash:
- code = _graphQLData[++_position];
- if (!GraphQLConstants.IsValidEscapeCharacter(code))
- {
- throw new SyntaxException(this,
- $"Invalid character escape sequence: \\{code}.");
- }
- break;
-
- // SourceCharacter
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 11:
- case 12:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- case 127:
+ return;
+ }
+ else if (code == Quote)
+ {
+ _kind = TokenKind.String;
+ _start = start;
+ _end = _position;
+ _value = _graphQLData.Slice(start + 1, _position - start - 1);
+ _position++;
+ return;
+ }
+ else if (code == Backslash)
+ {
+ code = _graphQLData[++_position];
+ if (!_isEscapeCharacter[code])
+ {
throw new SyntaxException(this,
- $"Invalid character within String: {code}.");
+ $"Invalid character escape sequence: \\{code}.");
+ }
+ }
+ else if (_isControlCharacter[code])
+ {
+ throw new SyntaxException(this,
+ $"Invalid character within String: {code}.");
}
}
@@ -485,80 +415,49 @@ private void ReadBlockStringToken()
{
byte code = _graphQLData[_position];
- switch (code)
+ if (code == NewLine)
{
- case GraphQLConstants.NewLine:
- _nextNewLines++;
- break;
-
- case GraphQLConstants.Return:
- int next = _position + 1;
- if (next < _length
- && _graphQLData[next] == GraphQLConstants.NewLine)
- {
- _position = next;
- }
- _nextNewLines++;
- break;
-
- // Closing Triple-Quote (""")
- case GraphQLConstants.Quote:
- if (_graphQLData[_position + 1] == GraphQLConstants.Quote
- && _graphQLData[_position + 2] == GraphQLConstants.Quote)
- {
- _kind = TokenKind.BlockString;
- _start = start;
- _end = _position + 2;
- _value = _graphQLData.Slice(
- start + 3,
- _position - start - 3);
- _position = _end + 1;
- return;
- }
- break;
-
- case GraphQLConstants.Backslash:
- if (_graphQLData[_position + 1] == GraphQLConstants.Quote
- && _graphQLData[_position + 2] == GraphQLConstants.Quote
- && _graphQLData[_position + 3] == GraphQLConstants.Quote)
- {
- _position += 3;
- }
- break;
-
- // SourceCharacter
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 11:
- case 12:
- case 14:
- case 15:
- case 16:
- case 17:
- case 18:
- case 19:
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- case 127:
- throw new SyntaxException(this,
- $"Invalid character within String: {code}.");
+ _nextNewLines++;
+ }
+ else if (code == Return)
+ {
+ int next = _position + 1;
+ if (next < _length
+ && _graphQLData[next] == NewLine)
+ {
+ _position = next;
+ }
+ _nextNewLines++;
+ }
+ else if (code == Quote)
+ {
+ if (_graphQLData[_position + 1] == GraphQLConstants.Quote
+ && _graphQLData[_position + 2] == GraphQLConstants.Quote)
+ {
+ _kind = TokenKind.BlockString;
+ _start = start;
+ _end = _position + 2;
+ int valueStart = _start + 3;
+ int valueEnd = _end - 3;
+ int valueLength = valueEnd - valueStart;
+ _value = _graphQLData.Slice(valueStart, valueLength);
+ _position = _end + 1;
+ return;
+ }
+ }
+ else if (code == Backslash)
+ {
+ if (_graphQLData[_position + 1] == GraphQLConstants.Quote
+ && _graphQLData[_position + 2] == GraphQLConstants.Quote
+ && _graphQLData[_position + 3] == GraphQLConstants.Quote)
+ {
+ _position += 3;
+ }
+ }
+ else if (_isControlCharacterNoNewLine[code])
+ {
+ throw new SyntaxException(this,
+ $"Invalid character within String: {code}.");
}
}
@@ -570,7 +469,7 @@ private void SkipWhitespaces()
{
if (_nextNewLines > 0)
{
- NewLine(_nextNewLines);
+ SetNewLine(_nextNewLines);
_nextNewLines = 0;
}
@@ -580,23 +479,23 @@ private void SkipWhitespaces()
switch (code)
{
- case GraphQLConstants.NewLine:
+ case NewLine:
++_position;
- NewLine();
+ SetNewLine();
break;
- case GraphQLConstants.Return:
+ case Return:
if (++_position < _length
- && _graphQLData[_position] == GraphQLConstants.NewLine)
+ && _graphQLData[_position] == NewLine)
{
++_position;
}
- NewLine();
+ SetNewLine();
break;
- case GraphQLConstants.Tab:
- case GraphQLConstants.Space:
- case GraphQLConstants.Comma:
+ case Tab:
+ case Space:
+ case Comma:
++_position;
break;
@@ -633,7 +532,7 @@ private void SkipBoml()
/// Sets the state to a new line.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void NewLine()
+ public void SetNewLine()
{
_line++;
_lineStart = _position;
@@ -647,7 +546,7 @@ public void NewLine()
/// The number of lines to skip.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- public void NewLine(int lines)
+ public void SetNewLine(int lines)
{
if (lines < 1)
{