All Projects → graphql-dotnet → Parser

graphql-dotnet / Parser

Licence: mit
A lexer and parser for GraphQL in .NET

Projects that are alternatives of or similar to Parser

Swiftpascalinterpreter
Simple Swift interpreter for the Pascal language inspired by the Let’s Build A Simple Interpreter article series.
Stars: ✭ 270 (+65.64%)
Mutual labels:  ast, lexer, parse
pascal-interpreter
A simple interpreter for a large subset of Pascal language written for educational purposes
Stars: ✭ 21 (-87.12%)
Mutual labels:  parse, ast, lexer
Libpypa
libpypa is a Python parser implemented in pure C++
Stars: ✭ 172 (+5.52%)
Mutual labels:  ast, lexer, parse
Graphql Go Tools
Tools to write high performance GraphQL applications using Go/Golang.
Stars: ✭ 96 (-41.1%)
Mutual labels:  graphql, ast, lexer
Snapdragon
snapdragon is an extremely pluggable, powerful and easy-to-use parser-renderer factory.
Stars: ✭ 180 (+10.43%)
Mutual labels:  ast, lexer, parse
parse-function
(!! moved to tunnckoCore/opensource multi-package repository !!) 🔱 Parse a function into an object using espree, acorn or babylon parsers. Extensible through Smart Plugins.
Stars: ✭ 37 (-77.3%)
Mutual labels:  parse, ast
Babel Plugin Import Graphql
Enables import syntax for .graphql and .gql files
Stars: ✭ 284 (+74.23%)
Mutual labels:  graphql, parse
Exprtk
C++ Mathematical Expression Parsing And Evaluation Library
Stars: ✭ 301 (+84.66%)
Mutual labels:  ast, lexer
Micromark
the smallest commonmark compliant markdown parser that exists; new basis for @unifiedjs (hundreds of projects w/ billions of downloads for dealing w/ content)
Stars: ✭ 793 (+386.5%)
Mutual labels:  ast, parse
ocean
Programming language that compiles into a x86 ELF executable.
Stars: ✭ 164 (+0.61%)
Mutual labels:  ast, lexer
Php Parser
🌿 NodeJS PHP Parser - extract AST or tokens (PHP5 and PHP7)
Stars: ✭ 400 (+145.4%)
Mutual labels:  ast, lexer
Graphql Factory
A toolkit for building GraphQL
Stars: ✭ 44 (-73.01%)
Mutual labels:  graphql, ast
bredon
A modern CSS value compiler in JavaScript
Stars: ✭ 39 (-76.07%)
Mutual labels:  ast, lexer
eval-estree-expression
Safely evaluate JavaScript (estree) expressions, sync and async.
Stars: ✭ 22 (-86.5%)
Mutual labels:  parse, ast
Csstree
A tool set for CSS including fast detailed parser, walker, generator and lexer based on W3C specs and browser implementations
Stars: ✭ 1,121 (+587.73%)
Mutual labels:  ast, lexer
Charly Vm
Fibers, Closures, C-Module System | NaN-boxing, bytecode-VM written in C++
Stars: ✭ 66 (-59.51%)
Mutual labels:  ast, lexer
Tiny Compiler
A tiny compiler for a language featuring LL(2) with Lexer, Parser, ASM-like codegen and VM. Complex enough to give you a flavour of how the "real" thing works whilst not being a mere toy example
Stars: ✭ 425 (+160.74%)
Mutual labels:  ast, lexer
Bash Parser
Parses bash into an AST
Stars: ✭ 151 (-7.36%)
Mutual labels:  ast, parse
abstract-syntax-tree
A library for working with abstract syntax trees.
Stars: ✭ 77 (-52.76%)
Mutual labels:  parse, ast
astutils
Bare essentials for building abstract syntax trees, and skeleton classes for PLY lexers and parsers.
Stars: ✭ 13 (-92.02%)
Mutual labels:  parse, ast

GraphQL Dotnet Parser

Run unit tests Publish preview to GitHub registry Publish release to Nuget registry CodeQL analysis

NuGet Nuget

Activity Activity Activity

Size

codecov Total alerts Language grade: C#

This library contains a lexer and parser classes as well as the complete GraphQL AST model.

The parser from this library is used in GraphQL for .NET.

Preview versions of this package are available on GitHub Packages.

Lexer

Generates token based on input text. Lexer takes advantage of ReadOnlyMemory<char> and in most cases does not allocate memory on the managed heap at all.

Usage

var token = Lexer.Lex("\"str\"");

Lex method always returns the first token it finds. In this case case the result would look like following. lexer example

Parser

Parses provided GraphQL expression into AST (abstract syntax tree). Parser also takes advantage of ReadOnlyMemory<char> but still allocates memory for AST.

Usage

var ast1 = Parser.Parse(@"
{
  field
}");

var ast2 = Parser.Parse(@"
{
  field
}", new ParserOptions { Ignore = IgnoreOptions.IgnoreComments });

By default ParserOptions.Ignore is IgnoreOptions.IgnoreComments to improve performance. If you don't need information about tokens locations in the source document, then use IgnoreOptions.IgnoreCommentsAndLocations. This will maximize the saving of memory allocated in the managed heap for AST.

Example of json representation of the resulting AST

{
  "Definitions": [{
    "Directives": [],
    "Kind": 2,
    "Name": null,
    "Operation": 0,
    "SelectionSet": {
      "Kind": 5,
      "Selections": [{
        "Alias": null,
        "Arguments": [],
        "Directives": [],
        "Kind": 6,
        "Name": {
          "Kind": 0,
          "Value": "field",
          "Location": {
            "End": 50,
            "Start": 31
          }
        },
        "SelectionSet": null,
        "Location": {
          "End": 50,
          "Start": 31
        }
      }],
      "Location": {
        "End": 50,
        "Start": 13
      }
    },
    "VariableDefinitions": null,
    "Location": {
      "End": 50,
      "Start": 13
    }
  }],
  "Kind": 1,
  "Location": {
    "End": 50,
    "Start": 13
  }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].