Skip to content

Commit

Permalink
ccan: update, add graphql module.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Dec 14, 2021
1 parent a98ccac commit 064e239
Show file tree
Hide file tree
Showing 7 changed files with 4,505 additions and 1 deletion.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ CCAN_HEADERS := \
$(CCANDIR)/ccan/endian/endian.h \
$(CCANDIR)/ccan/err/err.h \
$(CCANDIR)/ccan/fdpass/fdpass.h \
$(CCANDIR)/ccan/graphql/graphql.h \
$(CCANDIR)/ccan/htable/htable.h \
$(CCANDIR)/ccan/htable/htable_type.h \
$(CCANDIR)/ccan/ilog/ilog.h \
Expand Down
2 changes: 1 addition & 1 deletion ccan/README
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
CCAN imported from http://ccodearchive.net.

CCAN version: init-2520-gca7c5a9e
CCAN version: init-2522-g21543f83
1 change: 1 addition & 0 deletions ccan/ccan/graphql/LICENSE
66 changes: 66 additions & 0 deletions ccan/ccan/graphql/_info
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#include "config.h"
#include <stdio.h>
#include <string.h>

/**
* graphql - Routines to lex and parse GraphQL.
*
* This code contains routines to lex and parse GraphQL code.
* This code was written per the spec at:
* https://spec.graphql.org/draft/
* ...dated Fri, May 21, 2021 at the time of writing.
* Copyright (c) 2021 WhiteCloudFarm.org <[email protected]>
* <https://github.com/rl-d/ccan>
*
* Example:
*
* int main(int argc, char *argv[]) {
*
* const char *input_string = "{ fieldName }";
* struct list_head *output_tokens;
* struct graphql_executable_document *output_document;
*
* const char *errmsg = graphql_lexparse(
* NULL, // tal context
* input_string,
* &output_tokens, // variable to receive tokens
* &output_document); // variable to receive AST
*
* if (errmsg) {
* struct graphql_token *last_token;
* last_token = list_tail(output_tokens, struct graphql_token, node);
* printf("Line %d, col %d: %s",
* last_token->source_line,
* last_token->source_column + last_token->source_len,
* errmsg);
* } else {
* // Normally you would check every indirection in the resulting AST for null
* // pointers, but for simplicity of example:
* printf("A field from the parsed string: %s\n",
* output_document->first_def->op_def->sel_set->
* first->field->name->token_string);
* }
*
* output_tokens = tal_free(output_tokens);
* }
*
* License: BSD-MIT
*/
int main(int argc, char *argv[])
{
/* Expect exactly one argument */
if (argc != 2)
return 1;

if (strcmp(argv[1], "depends") == 0) {
printf("ccan/list\n");
printf("ccan/str\n");
printf("ccan/tal\n");
printf("ccan/tal/str\n");
printf("ccan/utf8\n");
return 0;
}

return 1;
}

Loading

0 comments on commit 064e239

Please sign in to comment.