···
import { match, parse as makeParser } from 'reghex';
// 2.1.7: Includes commas, and line comments
-
const ignored = match()`
-
${/([\s,]|#[^\n\r]+)+/}
// 2.1.9: Limited to ASCII character set, so regex shortcodes are fine
const name = match(Kind.NAME, (x) => ({
···
const variable = match(Kind.VARIABLE, (x) => ({
···
const list = match(Kind.LIST, (x) => ({
-
(?: ${'['} ${ignored}?)
-
(?: ${']'} ${ignored}?)
const objectField = match(Kind.OBJECT_FIELD, (x) => ({
···
-
(?: ${ignored} ${/:/} ${ignored})?
const object = match(Kind.OBJECT, (x) => ({
-
(?: ${'{'} ${ignored}?)
···
-
(?: ${ignored} ${'on'} ${ignored})
···
-
(?: ${'...'} ${ignored}?)
···
···
const varDefinitions = match('vars')`
···
-
name: x.length === 5 ? x[i++] : undefined,
-
variableDefinitions: x[i].tag === 'vars' ? x[i++].slice() : null,
${/query|mutation|subscription/}
-
((?: ${ignored}) ${name})?
···
···
import { match, parse as makeParser } from 'reghex';
// 2.1.7: Includes commas, and line comments
+
const ignored = /([\s,]|#[^\n\r]+)+/;
// 2.1.9: Limited to ASCII character set, so regex shortcodes are fine
const name = match(Kind.NAME, (x) => ({
···
const variable = match(Kind.VARIABLE, (x) => ({
···
const list = match(Kind.LIST, (x) => ({
+
(?: ${ignored}? ${']'} ${ignored}?)
const objectField = match(Kind.OBJECT_FIELD, (x) => ({
···
+
(?: ${ignored}? ${':'})
const object = match(Kind.OBJECT, (x) => ({
···
+
(?: ${ignored}? ${'on'} ${ignored})
···
···
···
const varDefinitions = match('vars')`
···
+
name: x[i].kind === Kind.NAME ? x[i++] : undefined,
+
variableDefinitions: x[i].tag === 'vars' ? x[i++].slice() : [],
${/query|mutation|subscription/}
···