Add libgraphqlparser 0.7.0
libgraphqlparser is a parser for GraphQL, a query language for describing data requirements on complex application data models, implemented in C++11. It can be used on its own in C++ code (or in C code via the pure C API defined in the c subdirectory), or you can use it as the basis for an extension module for your favorite programming language instead of writing your own parser from scratch. WWW: https://github.com/graphql/libgraphqlparser
This commit is contained in:
parent
d76a18f1e4
commit
f0508af695
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=533810
16 changed files with 636 additions and 0 deletions
|
@ -1216,6 +1216,7 @@
|
|||
SUBDIR += libgpc
|
||||
SUBDIR += libgpkg
|
||||
SUBDIR += libgrading
|
||||
SUBDIR += libgraphqlparser
|
||||
SUBDIR += libgsf
|
||||
SUBDIR += libgta
|
||||
SUBDIR += libgtop
|
||||
|
|
21
devel/libgraphqlparser/Makefile
Normal file
21
devel/libgraphqlparser/Makefile
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Created by: Po-Chuan Hsieh <sunpoet@FreeBSD.org>
|
||||
# $FreeBSD$
|
||||
|
||||
PORTNAME= libgraphqlparser
|
||||
PORTVERSION= 0.7.0
|
||||
DISTVERSIONPREFIX= v
|
||||
CATEGORIES= devel
|
||||
#MASTER_SITES=
|
||||
|
||||
MAINTAINER= sunpoet@FreeBSD.org
|
||||
COMMENT= GraphQL query parser
|
||||
|
||||
LICENSE= MIT
|
||||
LICENSE_FILE= ${WRKSRC}/LICENSE
|
||||
|
||||
USES= bison cmake compiler:c++11-lang python:3.6+,build
|
||||
|
||||
USE_GITHUB= yes
|
||||
GH_ACCOUNT= graphql
|
||||
|
||||
.include <bsd.port.mk>
|
3
devel/libgraphqlparser/distinfo
Normal file
3
devel/libgraphqlparser/distinfo
Normal file
|
@ -0,0 +1,3 @@
|
|||
TIMESTAMP = 1588450778
|
||||
SHA256 (graphql-libgraphqlparser-v0.7.0_GH0.tar.gz) = 63dae018f970dc2bdce431cbafbfa0bd3e6b10bba078bb997a3c1a40894aa35c
|
||||
SIZE (graphql-libgraphqlparser-v0.7.0_GH0.tar.gz) = 79853
|
15
devel/libgraphqlparser/files/patch-CMakeLists.txt
Normal file
15
devel/libgraphqlparser/files/patch-CMakeLists.txt
Normal file
|
@ -0,0 +1,15 @@
|
|||
--- CMakeLists.txt.orig 2017-10-16 21:39:41 UTC
|
||||
+++ CMakeLists.txt
|
||||
@@ -7,9 +7,9 @@ INCLUDE(version)
|
||||
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||
|
||||
-FIND_PACKAGE(PythonInterp 2 REQUIRED)
|
||||
-IF (NOT PYTHON_VERSION_MAJOR EQUAL 2)
|
||||
- MESSAGE(FATAL_ERROR "Python 2 is required.")
|
||||
+FIND_PACKAGE(PythonInterp 3 REQUIRED)
|
||||
+IF (NOT PYTHON_VERSION_MAJOR EQUAL 3)
|
||||
+ MESSAGE(FATAL_ERROR "Python 3 is required.")
|
||||
ENDIF()
|
||||
|
||||
FIND_PROGRAM(CTYPESGEN_FOUND ctypesgen.py)
|
53
devel/libgraphqlparser/files/patch-ast-c.py
Normal file
53
devel/libgraphqlparser/files/patch-ast-c.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
--- ast/c.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/c.py
|
||||
@@ -62,7 +62,7 @@ class Printer(object):
|
||||
self._current_type = None
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '''/** @generated */
|
||||
+ print(C_LICENSE_COMMENT + '''/** @generated */
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -70,33 +70,33 @@ class Printer(object):
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
-'''
|
||||
+''')
|
||||
|
||||
def end_file(self):
|
||||
- print '''
|
||||
+ print('''
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
-'''
|
||||
+''')
|
||||
|
||||
def start_type(self, name):
|
||||
# Forward declarations for AST nodes.
|
||||
st_name = struct_name(name)
|
||||
- print 'struct ' + st_name + ';'
|
||||
+ print('struct ' + st_name + ';')
|
||||
self._current_type = name
|
||||
|
||||
def field(self, type, name, nullable, plural):
|
||||
- print field_prototype(self._current_type, type, name, nullable, plural) + ';'
|
||||
+ print(field_prototype(self._current_type, type, name, nullable, plural) + ';')
|
||||
|
||||
def end_type(self, name):
|
||||
- print
|
||||
+ print()
|
||||
|
||||
def start_union(self, name):
|
||||
- print 'struct ' + struct_name(name) + ';'
|
||||
+ print('struct ' + struct_name(name) + ';')
|
||||
|
||||
def union_option(self, option):
|
||||
pass
|
||||
|
||||
def end_union(self, name):
|
||||
- print
|
||||
+ print()
|
49
devel/libgraphqlparser/files/patch-ast-c_impl.py
Normal file
49
devel/libgraphqlparser/files/patch-ast-c_impl.py
Normal file
|
@ -0,0 +1,49 @@
|
|||
--- ast/c_impl.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/c_impl.py
|
||||
@@ -17,13 +17,13 @@ class Printer(object):
|
||||
self._current_type = None
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '''/** @generated */
|
||||
+ print(C_LICENSE_COMMENT + '''/** @generated */
|
||||
|
||||
#include "GraphQLAst.h"
|
||||
#include "../Ast.h"
|
||||
|
||||
using namespace facebook::graphql::ast;
|
||||
-'''
|
||||
+''')
|
||||
|
||||
def end_file(self):
|
||||
pass
|
||||
@@ -32,23 +32,23 @@ using namespace facebook::graphql::ast;
|
||||
self._current_type = name
|
||||
|
||||
def field(self, type, name, nullable, plural):
|
||||
- print field_prototype(self._current_type, type, name, nullable, plural) + ' {'
|
||||
- print ' const auto *realNode = (const %s *)node;' % self._current_type
|
||||
+ print(field_prototype(self._current_type, type, name, nullable, plural) + ' {')
|
||||
+ print(' const auto *realNode = (const %s *)node;' % self._current_type)
|
||||
title_name = title(name)
|
||||
call_get = 'realNode->get%s()' % title_name
|
||||
if plural:
|
||||
if nullable:
|
||||
- print ' return %s ? %s->size() : 0;' % (call_get, call_get)
|
||||
+ print(' return %s ? %s->size() : 0;' % (call_get, call_get))
|
||||
else:
|
||||
- print ' return %s.size();' % call_get
|
||||
+ print(' return %s.size();' % call_get)
|
||||
else:
|
||||
if type in ['string', 'OperationKind', 'boolean']:
|
||||
- print ' return %s;' % call_get
|
||||
+ print(' return %s;' % call_get)
|
||||
else:
|
||||
fmt = ' return (const struct %s *)%s%s;'
|
||||
- print fmt % (struct_name(type), '' if nullable else '&', call_get)
|
||||
+ print(fmt % (struct_name(type), '' if nullable else '&', call_get))
|
||||
|
||||
- print '}'
|
||||
+ print('}')
|
||||
|
||||
def end_type(self, name):
|
||||
pass
|
22
devel/libgraphqlparser/files/patch-ast-c_visitor_impl.py
Normal file
22
devel/libgraphqlparser/files/patch-ast-c_visitor_impl.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
--- ast/c_visitor_impl.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/c_visitor_impl.py
|
||||
@@ -16,8 +16,8 @@ class Printer(object):
|
||||
self._types = []
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '/** @generated */'
|
||||
- print '#define FOR_EACH_CONCRETE_TYPE(MACRO) \\'
|
||||
+ print(C_LICENSE_COMMENT + '/** @generated */')
|
||||
+ print('#define FOR_EACH_CONCRETE_TYPE(MACRO) \\')
|
||||
|
||||
def start_type(self, name):
|
||||
self._types.append(name)
|
||||
@@ -29,7 +29,7 @@ class Printer(object):
|
||||
pass
|
||||
|
||||
def end_file(self):
|
||||
- print ' \\\n'.join('MACRO(%s, %s)' % (name, snake(name)) for name in self._types)
|
||||
+ print(' \\\n'.join('MACRO(%s, %s)' % (name, snake(name)) for name in self._types))
|
||||
|
||||
def start_union(self, name):
|
||||
pass
|
173
devel/libgraphqlparser/files/patch-ast-cxx.py
Normal file
173
devel/libgraphqlparser/files/patch-ast-cxx.py
Normal file
|
@ -0,0 +1,173 @@
|
|||
--- ast/cxx.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/cxx.py
|
||||
@@ -5,7 +5,7 @@
|
||||
# LICENSE file in the root directory of this source tree. An additional grant
|
||||
# of patent rights can be found in the PATENTS file in the same directory.
|
||||
|
||||
-import cStringIO as StringIO
|
||||
+import io as StringIO
|
||||
|
||||
from casing import title
|
||||
from license import C_LICENSE_COMMENT
|
||||
@@ -23,7 +23,7 @@ class Printer(object):
|
||||
self._fields = []
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '''/** @generated */
|
||||
+ print(C_LICENSE_COMMENT + '''/** @generated */
|
||||
#pragma once
|
||||
|
||||
#include "AstNode.h"
|
||||
@@ -42,14 +42,14 @@ namespace ast {
|
||||
struct CDeleter {
|
||||
void operator()(const char *p) const { free((void *)p); }
|
||||
};
|
||||
-'''
|
||||
+''')
|
||||
|
||||
def end_file(self):
|
||||
- print
|
||||
- print self._deferredOutput.getvalue()
|
||||
- print '}'
|
||||
- print '}'
|
||||
- print '}'
|
||||
+ print()
|
||||
+ print(self._deferredOutput.getvalue())
|
||||
+ print('}')
|
||||
+ print('}')
|
||||
+ print('}')
|
||||
|
||||
def _base_class(self, type):
|
||||
return self._bases.get(type, 'Node')
|
||||
@@ -58,8 +58,8 @@ struct CDeleter {
|
||||
self._type_name = name
|
||||
base = self._base_class(name)
|
||||
# non-deferred!
|
||||
- print 'class %s;' % name
|
||||
- print >> self._deferredOutput, 'class %s : public %s {' % (name, base)
|
||||
+ print('class %s;' % name)
|
||||
+ print('class %s : public %s {' % (name, base), file=self._deferredOutput)
|
||||
self._fields = []
|
||||
|
||||
def field(self, type, name, nullable, plural):
|
||||
@@ -69,18 +69,18 @@ struct CDeleter {
|
||||
|
||||
def end_type(self, name):
|
||||
self._print_fields()
|
||||
- print >> self._deferredOutput, ' public:'
|
||||
+ print(' public:', file=self._deferredOutput)
|
||||
self._print_constructor()
|
||||
- print >> self._deferredOutput
|
||||
+ print(file=self._deferredOutput)
|
||||
self._print_destructor_prototype()
|
||||
- print >> self._deferredOutput
|
||||
+ print(file=self._deferredOutput)
|
||||
self._print_noncopyable()
|
||||
- print >> self._deferredOutput
|
||||
+ print(file=self._deferredOutput)
|
||||
self._print_getters()
|
||||
- print >> self._deferredOutput, ' void accept(visitor::AstVisitor *visitor) const override;'
|
||||
- print >> self._deferredOutput, '};'
|
||||
- print >> self._deferredOutput
|
||||
- print >> self._deferredOutput
|
||||
+ print(' void accept(visitor::AstVisitor *visitor) const override;', file=self._deferredOutput)
|
||||
+ print('};', file=self._deferredOutput)
|
||||
+ print(file=self._deferredOutput)
|
||||
+ print(file=self._deferredOutput)
|
||||
self._type_name = None
|
||||
self._fields = []
|
||||
|
||||
@@ -97,7 +97,7 @@ struct CDeleter {
|
||||
storage_type = self._storage_type(type)
|
||||
if plural:
|
||||
storage_type = 'std::unique_ptr<std::vector<%s>>' % storage_type
|
||||
- print >> self._deferredOutput, ' %s %s_;' % (storage_type, name)
|
||||
+ print(' %s %s_;' % (storage_type, name), file=self._deferredOutput)
|
||||
|
||||
def _ctor_singular_type(self, type):
|
||||
if type == 'string':
|
||||
@@ -111,28 +111,28 @@ struct CDeleter {
|
||||
return 'std::vector<%s> *' % self._storage_type(type)
|
||||
|
||||
def _print_constructor(self):
|
||||
- print >> self._deferredOutput, ' explicit %s(' % self._type_name
|
||||
- print >> self._deferredOutput, ' const yy::location &location%s' % (',' if self._fields else '')
|
||||
+ print(' explicit %s(' % self._type_name, file=self._deferredOutput)
|
||||
+ print(' const yy::location &location%s' % (',' if self._fields else ''), file=self._deferredOutput)
|
||||
def ctor_arg(type, name, plural):
|
||||
if plural:
|
||||
ctor_type = self._ctor_plural_type(type)
|
||||
else:
|
||||
ctor_type = self._ctor_singular_type(type)
|
||||
return ' %s %s' % (ctor_type, name)
|
||||
- print >> self._deferredOutput, ',\n'.join(ctor_arg(type, name, plural)
|
||||
- for (type, name, nullable, plural) in self._fields)
|
||||
- print >> self._deferredOutput, ' )'
|
||||
+ print(',\n'.join(ctor_arg(type, name, plural)
|
||||
+ for (type, name, nullable, plural) in self._fields), file=self._deferredOutput)
|
||||
+ print(' )', file=self._deferredOutput)
|
||||
def ctor_init(type, name, plural):
|
||||
# Strings are const char *, just pass.
|
||||
# Vectors are passed by pointer and we take ownership.
|
||||
# Node types are passed in by pointer and we take ownership.
|
||||
value = name
|
||||
return ' %s_(%s)' % (name, value)
|
||||
- print >> self._deferredOutput, ' : %s(location)%s' % (self._base_class(self._type_name), ',' if self._fields else '')
|
||||
- print >> self._deferredOutput, ',\n'.join(ctor_init(type, name, plural)
|
||||
+ print(' : %s(location)%s' % (self._base_class(self._type_name), ',' if self._fields else ''), file=self._deferredOutput)
|
||||
+ print(',\n'.join(ctor_init(type, name, plural)
|
||||
for (type, name, nullable, plural)
|
||||
- in self._fields)
|
||||
- print >> self._deferredOutput, ' {}'
|
||||
+ in self._fields), file=self._deferredOutput)
|
||||
+ print(' {}', file=self._deferredOutput)
|
||||
|
||||
def _getter_type(self, type, nullable, plural):
|
||||
if plural and nullable:
|
||||
@@ -165,31 +165,31 @@ struct CDeleter {
|
||||
|
||||
def _print_getters(self):
|
||||
for (type, name, nullable, plural) in self._fields:
|
||||
- print >> self._deferredOutput, ' %s get%s() const' % (
|
||||
+ print(' %s get%s() const' % (
|
||||
self._getter_type(type, nullable, plural),
|
||||
- title(name))
|
||||
- print >> self._deferredOutput, ' { return %s; }' % (
|
||||
- self._getter_value_to_return(name + '_', type, nullable, plural))
|
||||
- print >> self._deferredOutput
|
||||
+ title(name)), file=self._deferredOutput)
|
||||
+ print(' { return %s; }' % (
|
||||
+ self._getter_value_to_return(name + '_', type, nullable, plural)), file=self._deferredOutput)
|
||||
+ print(file=self._deferredOutput)
|
||||
|
||||
def _print_destructor_prototype(self):
|
||||
- print >> self._deferredOutput, ' ~%s() {}' % self._type_name
|
||||
+ print(' ~%s() {}' % self._type_name, file=self._deferredOutput)
|
||||
|
||||
def _print_noncopyable(self):
|
||||
- print >> self._deferredOutput, ' %s(const %s&) = delete;' % (
|
||||
- self._type_name, self._type_name)
|
||||
- print >> self._deferredOutput, ' %s& operator=(const %s&) = delete;' % (
|
||||
- self._type_name, self._type_name)
|
||||
+ print(' %s(const %s&) = delete;' % (
|
||||
+ self._type_name, self._type_name), file=self._deferredOutput)
|
||||
+ print(' %s& operator=(const %s&) = delete;' % (
|
||||
+ self._type_name, self._type_name), file=self._deferredOutput)
|
||||
|
||||
def start_union(self, name):
|
||||
self._type_name = name
|
||||
# non-deferred!
|
||||
- print 'class %s;' % name
|
||||
- print >> self._deferredOutput, 'class %s : public Node {' % name
|
||||
- print >> self._deferredOutput, ' public:'
|
||||
+ print('class %s;' % name)
|
||||
+ print('class %s : public Node {' % name, file=self._deferredOutput)
|
||||
+ print(' public:', file=self._deferredOutput)
|
||||
self._print_constructor()
|
||||
- print >> self._deferredOutput, '};'
|
||||
- print >> self._deferredOutput
|
||||
+ print('};', file=self._deferredOutput)
|
||||
+ print(file=self._deferredOutput)
|
||||
|
||||
def union_option(self, type):
|
||||
assert type not in self._bases, '%s cannot appear in more than one union!' % type
|
58
devel/libgraphqlparser/files/patch-ast-cxx_impl.py
Normal file
58
devel/libgraphqlparser/files/patch-ast-cxx_impl.py
Normal file
|
@ -0,0 +1,58 @@
|
|||
--- ast/cxx_impl.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/cxx_impl.py
|
||||
@@ -12,7 +12,7 @@ class Printer(object):
|
||||
pass
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '''/** @generated */
|
||||
+ print(C_LICENSE_COMMENT + '''/** @generated */
|
||||
|
||||
#include "Ast.h"
|
||||
#include "AstVisitor.h"
|
||||
@@ -20,17 +20,17 @@ class Printer(object):
|
||||
namespace facebook {
|
||||
namespace graphql {
|
||||
namespace ast {
|
||||
-'''
|
||||
+''')
|
||||
|
||||
def end_file(self):
|
||||
- print '}'
|
||||
- print '}'
|
||||
- print '}'
|
||||
+ print('}')
|
||||
+ print('}')
|
||||
+ print('}')
|
||||
|
||||
def start_type(self, name):
|
||||
- print '''void %s::accept(visitor::AstVisitor *visitor) const {
|
||||
+ print('''void %s::accept(visitor::AstVisitor *visitor) const {
|
||||
if (visitor->visit%s(*this)) {
|
||||
-''' % (name, name)
|
||||
+''' % (name, name))
|
||||
|
||||
def field(self, type, name, nullable, plural):
|
||||
if type in ['OperationKind', 'string', 'boolean']:
|
||||
@@ -40,18 +40,18 @@ namespace ast {
|
||||
accept = '{ for (const auto &x : *%s_) { x->accept(visitor); } }' % name
|
||||
if nullable:
|
||||
accept = 'if (%s_) %s' % (name, accept)
|
||||
- print ' ' + accept
|
||||
+ print(' ' + accept)
|
||||
else:
|
||||
accept = '%s_->accept(visitor);' % name
|
||||
if nullable:
|
||||
accept = 'if (%s_) { %s }' % (name, accept)
|
||||
- print ' ' + accept
|
||||
+ print(' ' + accept)
|
||||
|
||||
def end_type(self, name):
|
||||
- print ''' }
|
||||
+ print(''' }
|
||||
visitor->endVisit%s(*this);
|
||||
}
|
||||
-''' % name
|
||||
+''' % name)
|
||||
|
||||
def start_union(self, name):
|
||||
pass
|
|
@ -0,0 +1,24 @@
|
|||
--- ast/cxx_json_visitor_header.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/cxx_json_visitor_header.py
|
||||
@@ -13,7 +13,7 @@ class Printer(object):
|
||||
self._anyFieldIsANode = False
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '/** @generated */'
|
||||
+ print(C_LICENSE_COMMENT + '/** @generated */')
|
||||
|
||||
def end_file(self):
|
||||
pass
|
||||
@@ -24,9 +24,9 @@ class Printer(object):
|
||||
def end_type(self, name):
|
||||
titleName = title(name)
|
||||
if self._anyFieldIsANode:
|
||||
- print 'bool visit%s(const %s &node) override;' % (titleName, titleName)
|
||||
- print 'void endVisit%s(const %s &node) override;' % (titleName, titleName)
|
||||
- print
|
||||
+ print('bool visit%s(const %s &node) override;' % (titleName, titleName))
|
||||
+ print('void endVisit%s(const %s &node) override;' % (titleName, titleName))
|
||||
+ print()
|
||||
|
||||
def field(self, type, name, nullable, plural):
|
||||
if (not self._anyFieldIsANode and
|
|
@ -0,0 +1,64 @@
|
|||
--- ast/cxx_json_visitor_impl.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/cxx_json_visitor_impl.py
|
||||
@@ -13,7 +13,7 @@ class Printer(object):
|
||||
self._fields = []
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '/** @generated */'
|
||||
+ print(C_LICENSE_COMMENT + '/** @generated */')
|
||||
|
||||
def end_file(self):
|
||||
pass
|
||||
@@ -31,13 +31,13 @@ class Printer(object):
|
||||
anyFieldIsANode = any(type not in ('string, boolean')
|
||||
for (type, _, _ ,_) in self._fields)
|
||||
if anyFieldIsANode:
|
||||
- print '''bool JsonVisitor::visit%s(const %s &node) {
|
||||
+ print('''bool JsonVisitor::visit%s(const %s &node) {
|
||||
visitNode();
|
||||
return true;
|
||||
}
|
||||
-''' % (titleName, titleName)
|
||||
- print '''void JsonVisitor::endVisit%(tn)s(const %(tn)s &node) {
|
||||
- NodeFieldPrinter fields(*this, "%(tn)s", node);''' % {'tn': titleName}
|
||||
+''' % (titleName, titleName))
|
||||
+ print('''void JsonVisitor::endVisit%(tn)s(const %(tn)s &node) {
|
||||
+ NodeFieldPrinter fields(*this, "%(tn)s", node);''' % {'tn': titleName})
|
||||
|
||||
for (type, fieldName, nullable, plural) in self._fields:
|
||||
funcName = None
|
||||
@@ -49,7 +49,7 @@ class Printer(object):
|
||||
funcName = 'printSingularBooleanField'
|
||||
elif not nullable and not plural:
|
||||
# Special case: singular object fields don't need the value passed.
|
||||
- print ' fields.printSingularObjectField("%s");' % fieldName
|
||||
+ print(' fields.printSingularObjectField("%s");' % fieldName)
|
||||
continue
|
||||
else:
|
||||
nullable_str = 'Nullable' if nullable else ''
|
||||
@@ -57,19 +57,19 @@ class Printer(object):
|
||||
funcName = 'print%s%sField' % (nullable_str, plural_str)
|
||||
|
||||
assert funcName is not None
|
||||
- print ' fields.%s("%s", node.get%s());' % (
|
||||
- funcName, fieldName, title(fieldName))
|
||||
+ print(' fields.%s("%s", node.get%s());' % (
|
||||
+ funcName, fieldName, title(fieldName)))
|
||||
|
||||
if anyFieldIsANode:
|
||||
- print '''
|
||||
+ print('''
|
||||
endVisitNode(fields.finishPrinting());
|
||||
}
|
||||
-'''
|
||||
+''')
|
||||
else:
|
||||
- print '''
|
||||
+ print('''
|
||||
printed_.back().emplace_back(fields.finishPrinting());
|
||||
}
|
||||
-'''
|
||||
+''')
|
||||
|
||||
def start_union(self, name):
|
||||
pass
|
52
devel/libgraphqlparser/files/patch-ast-cxx_visitor.py
Normal file
52
devel/libgraphqlparser/files/patch-ast-cxx_visitor.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
--- ast/cxx_visitor.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/cxx_visitor.py
|
||||
@@ -13,7 +13,7 @@ class Printer(object):
|
||||
pass
|
||||
|
||||
def start_file(self):
|
||||
- print C_LICENSE_COMMENT + '''/** @generated */
|
||||
+ print(C_LICENSE_COMMENT + '''/** @generated */
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -27,28 +27,28 @@ namespace visitor {
|
||||
class AstVisitor {
|
||||
public:
|
||||
virtual ~AstVisitor() {}
|
||||
-'''
|
||||
+''')
|
||||
|
||||
def end_file(self):
|
||||
- print '};' # end AstVisitor
|
||||
- print
|
||||
- print '}'
|
||||
- print '}'
|
||||
- print '}'
|
||||
- print '}'
|
||||
+ print('};') # end AstVisitor
|
||||
+ print()
|
||||
+ print('}')
|
||||
+ print('}')
|
||||
+ print('}')
|
||||
+ print('}')
|
||||
|
||||
def start_type(self, name):
|
||||
titleName = title(name)
|
||||
camelName = camel(titleName)
|
||||
- print ' virtual bool visit%s(const %s &%s) { return true; }' % (
|
||||
+ print(' virtual bool visit%s(const %s &%s) { return true; }' % (
|
||||
titleName,
|
||||
titleName,
|
||||
- camelName)
|
||||
- print ' virtual void endVisit%s(const %s &%s) { }' % (
|
||||
+ camelName))
|
||||
+ print(' virtual void endVisit%s(const %s &%s) { }' % (
|
||||
titleName,
|
||||
titleName,
|
||||
- camelName)
|
||||
- print
|
||||
+ camelName))
|
||||
+ print()
|
||||
|
||||
def end_type(self, name):
|
||||
pass
|
59
devel/libgraphqlparser/files/patch-ast-js.py
Normal file
59
devel/libgraphqlparser/files/patch-ast-js.py
Normal file
|
@ -0,0 +1,59 @@
|
|||
--- ast/js.py.orig 2017-10-16 21:39:41 UTC
|
||||
+++ ast/js.py
|
||||
@@ -11,7 +11,7 @@ class Printer(object):
|
||||
pass
|
||||
|
||||
def start_file(self):
|
||||
- print '''/* @flow */
|
||||
+ print('''/* @flow */
|
||||
/* @generated */
|
||||
/* jshint ignore:start */
|
||||
|
||||
@@ -30,21 +30,21 @@ type Node = {
|
||||
end?: ?number;
|
||||
};
|
||||
|
||||
-type OperationKind = 'query' | 'mutation' | 'subscription';'''
|
||||
+type OperationKind = 'query' | 'mutation' | 'subscription';''')
|
||||
|
||||
def end_file(self):
|
||||
pass
|
||||
|
||||
def start_type(self, name):
|
||||
- print
|
||||
- print 'type %s = Node & {' % name
|
||||
+ print()
|
||||
+ print('type %s = Node & {' % name)
|
||||
kind = name
|
||||
if kind == 'GenericType':
|
||||
kind = 'Type'
|
||||
- print ' kind: \'%s\';' % kind
|
||||
+ print(' kind: \'%s\';' % kind)
|
||||
|
||||
def end_type(self, name):
|
||||
- print '}'
|
||||
+ print('}')
|
||||
|
||||
def _js_type(self, type, plural):
|
||||
if plural:
|
||||
@@ -54,16 +54,16 @@ type OperationKind = 'query' | 'mutation' | 'subscript
|
||||
def field(self, type, name, nullable, plural):
|
||||
nullable_char = '?' if nullable else ''
|
||||
js_type = self._js_type(type, plural)
|
||||
- print ' %(name)s%(nullable_char)s: %(nullable_char)s%(js_type)s;' % locals()
|
||||
+ print(' %(name)s%(nullable_char)s: %(nullable_char)s%(js_type)s;' % locals())
|
||||
|
||||
def start_union(self, name):
|
||||
- print ('type %s = ' % name),
|
||||
+ print(('type %s = ' % name), end=' ')
|
||||
self._current_options = []
|
||||
|
||||
def union_option(self, type):
|
||||
self._current_options.append(type)
|
||||
|
||||
def end_union(self, name):
|
||||
- print '\n | '.join(self._current_options)
|
||||
- print
|
||||
+ print('\n | '.join(self._current_options))
|
||||
+ print()
|
||||
self._current_options = None
|
17
devel/libgraphqlparser/files/patch-parser.ypp
Normal file
17
devel/libgraphqlparser/files/patch-parser.ypp
Normal file
|
@ -0,0 +1,17 @@
|
|||
--- parser.ypp.orig 2017-10-16 21:39:41 UTC
|
||||
+++ parser.ypp
|
||||
@@ -7,12 +7,12 @@
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
-%require "3"
|
||||
+%require "3.0"
|
||||
|
||||
%skeleton "lalr1.cc"
|
||||
|
||||
%defines
|
||||
-%define parser_class_name {GraphQLParserImpl}
|
||||
+%define api.parser.class {GraphQLParserImpl}
|
||||
|
||||
%define api.token.prefix {TOK_}
|
||||
|
7
devel/libgraphqlparser/pkg-descr
Normal file
7
devel/libgraphqlparser/pkg-descr
Normal file
|
@ -0,0 +1,7 @@
|
|||
libgraphqlparser is a parser for GraphQL, a query language for describing data
|
||||
requirements on complex application data models, implemented in C++11. It can be
|
||||
used on its own in C++ code (or in C code via the pure C API defined in the c
|
||||
subdirectory), or you can use it as the basis for an extension module for your
|
||||
favorite programming language instead of writing your own parser from scratch.
|
||||
|
||||
WWW: https://github.com/graphql/libgraphqlparser
|
18
devel/libgraphqlparser/pkg-plist
Normal file
18
devel/libgraphqlparser/pkg-plist
Normal file
|
@ -0,0 +1,18 @@
|
|||
include/graphqlparser/Ast.h
|
||||
include/graphqlparser/AstNode.h
|
||||
include/graphqlparser/AstVisitor.h
|
||||
include/graphqlparser/GraphQLParser.h
|
||||
include/graphqlparser/JsonVisitor.h
|
||||
include/graphqlparser/c/GraphQLAst.h
|
||||
include/graphqlparser/c/GraphQLAstForEachConcreteType.h
|
||||
include/graphqlparser/c/GraphQLAstNode.h
|
||||
include/graphqlparser/c/GraphQLAstToJSON.h
|
||||
include/graphqlparser/c/GraphQLAstVisitor.h
|
||||
include/graphqlparser/c/GraphQLParser.h
|
||||
include/graphqlparser/lexer.h
|
||||
include/graphqlparser/location.hh
|
||||
include/graphqlparser/parser.tab.hpp
|
||||
include/graphqlparser/position.hh
|
||||
include/graphqlparser/stack.hh
|
||||
include/graphqlparser/syntaxdefs.h
|
||||
lib/libgraphqlparser.so
|
Loading…
Reference in a new issue