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