How to use the graphql-language-service-parser.t function in graphql-language-service-parser

To help you get started, we’ve selected a few graphql-language-service-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql / graphiql / packages / codemirror-graphql / src / variables / mode.js View on Github external
}
        return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', opt(p(','))), p(']')],
  ObjectValue: [p('{'), list('ObjectField', opt(p(','))), p('}')],
  ObjectField: [namedKey('attribute'), p(':'), 'Value'],
};

// A namedKey Token which will decorate the state with a `name`
function namedKey(style) {
  return {
    style,
    match: token => token.kind === 'String',
    update(state, token) {
      state.name = token.value.slice(1, -1); // Remove quotes.
    },
  };
}
github graphql / graphiql / packages / codemirror-graphql / src / variables / mode.js View on Github external
return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', opt(p(','))), p(']')],
  ObjectValue: [p('{'), list('ObjectField', opt(p(','))), p('}')],
  ObjectField: [namedKey('attribute'), p(':'), 'Value'],
};

// A namedKey Token which will decorate the state with a `name`
function namedKey(style) {
  return {
    style,
    match: token => token.kind === 'String',
    update(state, token) {
      state.name = token.value.slice(1, -1); // Remove quotes.
    },
  };
}
github graphql / graphiql / packages / codemirror-graphql / src / results / mode.js View on Github external
// JSON Number.
  Number: /^-?(?:0|(?:[1-9][0-9]*))(?:\.[0-9]*)?(?:[eE][+-]?[0-9]+)?/,

  // JSON String.
  String: /^"(?:[^"\\]|\\(?:"|\/|\\|b|f|n|r|t|u[0-9a-fA-F]{4}))*"?/,

  // JSON literal keywords.
  Keyword: /^true|false|null/,
};

/**
 * The parser rules for JSON.
 */
const ParseRules = {
  Document: [p('{'), list('Entry', p(',')), p('}')],
  Entry: [t('String', 'def'), p(':'), 'Value'],
  Value(token) {
    switch (token.kind) {
      case 'Number':
        return 'NumberValue';
      case 'String':
        return 'StringValue';
      case 'Punctuation':
        switch (token.value) {
          case '[':
            return 'ListValue';
          case '{':
            return 'ObjectValue';
        }
        return null;
      case 'Keyword':
        switch (token.value) {
github graphql / graphiql / packages / codemirror-graphql / src / variables / mode.js View on Github external
case '{':
            return 'ObjectValue';
        }
        return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', opt(p(','))), p(']')],
  ObjectValue: [p('{'), list('ObjectField', opt(p(','))), p('}')],
  ObjectField: [namedKey('attribute'), p(':'), 'Value'],
};

// A namedKey Token which will decorate the state with a `name`
function namedKey(style) {
  return {
    style,
    match: token => token.kind === 'String',
    update(state, token) {
      state.name = token.value.slice(1, -1); // Remove quotes.
    },
github graphql / graphiql / packages / codemirror-graphql / src / variables / mode.js View on Github external
return 'ObjectValue';
        }
        return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', opt(p(','))), p(']')],
  ObjectValue: [p('{'), list('ObjectField', opt(p(','))), p('}')],
  ObjectField: [namedKey('attribute'), p(':'), 'Value'],
};

// A namedKey Token which will decorate the state with a `name`
function namedKey(style) {
  return {
    style,
    match: token => token.kind === 'String',
    update(state, token) {
      state.name = token.value.slice(1, -1); // Remove quotes.
    },
  };
github graphql / graphiql / packages / codemirror-graphql / src / results / mode.js View on Github external
case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', p(',')), p(']')],
  ObjectValue: [p('{'), list('ObjectField', p(',')), p('}')],
  ObjectField: [t('String', 'property'), p(':'), 'Value'],
};
github graphql / graphiql / packages / codemirror-graphql / src / results / mode.js View on Github external
}
        return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', p(',')), p(']')],
  ObjectValue: [p('{'), list('ObjectField', p(',')), p('}')],
  ObjectField: [t('String', 'property'), p(':'), 'Value'],
};
github graphql / graphiql / packages / codemirror-graphql / src / results / mode.js View on Github external
return 'ObjectValue';
        }
        return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', p(',')), p(']')],
  ObjectValue: [p('{'), list('ObjectField', p(',')), p('}')],
  ObjectField: [t('String', 'property'), p(':'), 'Value'],
};
github graphql / graphiql / packages / codemirror-graphql / src / results / mode.js View on Github external
return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', p(',')), p(']')],
  ObjectValue: [p('{'), list('ObjectField', p(',')), p('}')],
  ObjectField: [t('String', 'property'), p(':'), 'Value'],
};
github graphql / graphiql / packages / codemirror-graphql / src / results / mode.js View on Github external
case '{':
            return 'ObjectValue';
        }
        return null;
      case 'Keyword':
        switch (token.value) {
          case 'true':
          case 'false':
            return 'BooleanValue';
          case 'null':
            return 'NullValue';
        }
        return null;
    }
  },
  NumberValue: [t('Number', 'number')],
  StringValue: [t('String', 'string')],
  BooleanValue: [t('Keyword', 'builtin')],
  NullValue: [t('Keyword', 'keyword')],
  ListValue: [p('['), list('Value', p(',')), p(']')],
  ObjectValue: [p('{'), list('ObjectField', p(',')), p('}')],
  ObjectField: [t('String', 'property'), p(':'), 'Value'],
};