-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding experimental online parser (#2770)
* Adding experimental online parser * Improve Typings * Update grammar structure * Move rules to js * Fix build Co-authored-by: Ivan Goncharov <[email protected]>
- Loading branch information
1 parent
3b10b17
commit 13ece49
Showing
7 changed files
with
2,890 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
## Experimental Online Parser | ||
|
||
This directory contains an experimental online parser based on JSON rules set. It is a state-full parser which parses a source string incrementally i.e. emits a token each time. | ||
|
||
The parser is being migrated from graphiql to graphql-js and may have frequent breaking changes. | ||
|
||
Example: | ||
|
||
```js | ||
import { OnlineParser } from 'graphql/language/experimentalOnlineParser'; | ||
|
||
const source = ` | ||
query SomeQuery { | ||
some_field { | ||
another_field | ||
} | ||
} | ||
`; | ||
|
||
const parser = new OnlineParser(source); | ||
let token; | ||
|
||
do { | ||
token = parser.parseToken(); | ||
} while (token.kind !== '<EOF>' && token.kind !== 'Invalid'); | ||
``` |
Oops, something went wrong.