You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+55-46Lines changed: 55 additions & 46 deletions
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ The parser from this library is used in [GraphQL for .NET](https://github.com/gr
24
24
25
25
Preview versions of this package are available on [GitHub Packages](https://github.com/orgs/graphql-dotnet/packages?repo_name=parser).
26
26
27
-
## Lexer
27
+
## 1. Lexer
28
28
29
29
Generates token based on input text. Lexer takes advantage of `ReadOnlyMemory<char>` and in most cases
30
30
does not allocate memory on the managed heap at all.
@@ -38,7 +38,7 @@ var token = Lexer.Lex("\"str\"");
38
38
Lex method always returns the first token it finds. In this case case the result would look like following.
39
39

40
40
41
-
## Parser
41
+
## 2. Parser
42
42
43
43
Parses provided GraphQL expression into AST (abstract syntax tree). Parser also takes advantage of
44
44
`ReadOnlyMemory<char>` but still allocates memory for AST.
@@ -61,51 +61,60 @@ By default `ParserOptions.Ignore` is `IgnoreOptions.IgnoreComments` to improve p
61
61
If you don't need information about tokens locations in the source document, then use `IgnoreOptions.IgnoreCommentsAndLocations`.
62
62
This will maximize the saving of memory allocated in the managed heap for AST.
63
63
64
-
### Example of json representation of the resulting AST
64
+
##3. INodeVisitor
65
65
66
-
```json
66
+
`INodeVisitor` provides API to traverse AST of the parsed GraphQL document.
67
+
Default implementation of this interface is `DefaultNodeVisitor` that
68
+
traverses all AST nodes of the provided one. You can inherit from it and
69
+
implement your own AST processing algorithm.
70
+
71
+
For printing SDL from AST, you can use `SDLWriter<TContext>` visitor.
72
+
This is a highly optimized visitor for asynchronous non-blocking SDL output
73
+
into provided `TextWriter`. In the majority of cases it does not allocate
74
+
memory in the managed heap at all.
75
+
76
+
You can also find a `StructureWriter<TContext>` visitor that prints AST
77
+
into the provided `TextWriter` as a hierarchy of node types. It can be useful
78
+
when debugging for better understanding the AST structure.
79
+
Consider GraphQL document
80
+
81
+
```graphql
82
+
querya { nameage }
83
+
```
84
+
85
+
After `StructureWriter` processing the output text will be
0 commit comments