Skip to content

Commit

Permalink
Adding experimental online parser (#2770)
Browse files Browse the repository at this point in the history
* 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
thenamankumar and IvanGoncharov authored Sep 17, 2020
1 parent 3b10b17 commit 13ece49
Show file tree
Hide file tree
Showing 7 changed files with 2,890 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/language/experimentalOnlineParser/README.md
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');
```
Loading

0 comments on commit 13ece49

Please sign in to comment.