X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fgraphql%2F_info;fp=ccan%2Fgraphql%2F_info;h=efdb6a1395d78d7500c4bfaf52b82b000ee47520;hp=0000000000000000000000000000000000000000;hb=fda36378712fc7b2615f433cd670bc6300a3b0e1;hpb=05ec83512c478e03f0af460d304483ed292337d1 diff --git a/ccan/graphql/_info b/ccan/graphql/_info new file mode 100644 index 00000000..efdb6a13 --- /dev/null +++ b/ccan/graphql/_info @@ -0,0 +1,68 @@ +#include "config.h" +#include +#include + +/** + * 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 + * + * + * Example: + * #include + * #include "ccan/graphql/graphql.h" + * + * 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( + * input_string, + * NULL, // tal context + * &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, list); + * 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/take\n"); + printf("ccan/tal\n"); + printf("ccan/tal/str\n"); + printf("ccan/utf8\n"); + return 0; + } + + return 1; +} +