Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rustyrussell/ccan
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: kandycoder/ccan
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Oct 12, 2021

  1. Copy the full SHA
    8709b17 View commit details

Commits on Nov 15, 2021

  1. Miscellaneous improvements

    kandycoder committed Nov 15, 2021
    Copy the full SHA
    46d644f View commit details
  2. Code improvements

    kandycoder committed Nov 15, 2021
    Copy the full SHA
    899cde7 View commit details
Showing with 899 additions and 901 deletions.
  1. +2 −2 ccan/graphql/_info
  2. +382 −445 ccan/graphql/graphql.c
  3. +68 −7 ccan/graphql/graphql.h
  4. +447 −447 ccan/graphql/test/run.c
4 changes: 2 additions & 2 deletions ccan/graphql/_info
Original file line number Diff line number Diff line change
@@ -21,14 +21,14 @@
* struct graphql_executable_document *output_document;
*
* const char *errmsg = graphql_lexparse(
* input_string,
* 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, list);
* 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,
827 changes: 382 additions & 445 deletions ccan/graphql/graphql.c

Large diffs are not rendered by default.

75 changes: 68 additions & 7 deletions ccan/graphql/graphql.h
Original file line number Diff line number Diff line change
@@ -8,32 +8,37 @@
#include <ccan/tal/tal.h>

// Coding constants
#define GRAPHQL_SUCCESS 0
#define GRAPHQL_SUCCESS ((const char *)NULL)

// The following structures constitute the AST returned by the parser.

struct graphql_directive {
struct graphql_directive *next;
struct graphql_token *name;
struct graphql_arguments *args;
void *data; // for application use
};

struct graphql_directives {
struct graphql_directive *first;
void *data; // for application use
};

struct graphql_named_type {
struct graphql_token *name;
void *data; // for application use
};

struct graphql_type {
struct graphql_named_type *named;
// struct graphql_list_type *list;
// struct graphql_non_null_type *non_null;
void *data; // for application use
};

struct graphql_default_value {
struct graphql_value *val;
void *data; // for application use
};

struct graphql_variable_definition {
@@ -42,52 +47,64 @@ struct graphql_variable_definition {
struct graphql_type *type;
struct graphql_default_value *default_val;
struct graphql_directives *directives;
void *data; // for application use
};

struct graphql_variable_definitions {
struct graphql_variable_definition *first;
void *data; // for application use
};

struct graphql_variable {
struct graphql_token *name;
void *data; // for application use
};

struct graphql_object_field {
struct graphql_object_field *next;
struct graphql_token *name;
struct graphql_value *val;
void *data; // for application use
};

struct graphql_object_value {
struct graphql_object_field *first;
void *data; // for application use
};

struct graphql_list_value {
struct graphql_token *val;
void *data; // for application use
};

struct graphql_enum_value {
struct graphql_token *val;
void *data; // for application use
};

struct graphql_null_value {
struct graphql_token *val;
void *data; // for application use
};

struct graphql_string_value {
struct graphql_token *val;
void *data; // for application use
};

struct graphql_boolean_value {
struct graphql_token *val;
void *data; // for application use
};

struct graphql_float_value {
struct graphql_token *val;
void *data; // for application use
};

struct graphql_int_value {
struct graphql_token *val;
void *data; // for application use
};

struct graphql_value {
@@ -100,46 +117,55 @@ struct graphql_value {
struct graphql_enum_value *enum_val;
struct graphql_list_value *list_val;
struct graphql_object_value *obj_val;
void *data; // for application use
};

struct graphql_inline_fragment {
struct graphql_type_condition *type_cond;
struct graphql_directives *directives;
struct graphql_selection_set *sel_set;
void *data; // for application use
};

struct graphql_type_condition {
struct graphql_named_type *named_type;
void *data; // for application use
};

struct graphql_fragment_name {
struct graphql_token *name;
void *data; // for application use
};

struct graphql_fragment_definition {
struct graphql_fragment_name *name;
struct graphql_type_condition *type_cond;
struct graphql_directives *directives;
struct graphql_selection_set *sel_set;
void *data; // for application use
};

struct graphql_fragment_spread {
struct graphql_fragment_name *name;
struct graphql_directives *directives;
void *data; // for application use
};

struct graphql_alias {
struct graphql_token *name;
void *data; // for application use
};

struct graphql_argument {
struct graphql_argument *next;
struct graphql_token *name;
struct graphql_value *val;
void *data; // for application use
};

struct graphql_arguments {
struct graphql_argument *first;
void *data; // for application use
};

struct graphql_field {
@@ -148,21 +174,25 @@ struct graphql_field {
struct graphql_arguments *args;
struct graphql_directives *directives;
struct graphql_selection_set *sel_set;
void *data; // for application use
};

struct graphql_selection {
struct graphql_selection *next;
struct graphql_field *field;
struct graphql_fragment_spread *frag_spread;
struct graphql_inline_fragment *inline_frag;
void *data; // for application use
};

struct graphql_selection_set {
struct graphql_selection *first;
void *data; // for application use
};

struct graphql_operation_type {
struct graphql_token *op_type;
void *data; // for application use
};

struct graphql_operation_definition {
@@ -171,37 +201,63 @@ struct graphql_operation_definition {
struct graphql_variable_definitions *vars;
struct graphql_directives *directives;
struct graphql_selection_set *sel_set;
void *data; // for application use
};

struct graphql_executable_definition {
struct graphql_executable_definition *next_def;
struct graphql_operation_definition *op_def;
struct graphql_fragment_definition *frag_def;
void *data; // for application use
};

struct graphql_executable_document {
struct graphql_executable_definition *first_def;
void *data; // for application use
};

struct graphql_definition {
struct graphql_definition *next_def;
struct graphql_executable_definition *executable_def;
struct graphql_type_system_definition_or_extension *type_system_def;
void *data; // for application use
};

struct graphql_document {
struct graphql_definition *first_def;
void *data; // for application use
};

enum token_type_enum {
NAME = 'a',
INTEGER = 'i',
FLOAT = 'f',
STRING = 's',
PUNCT_BANG = '!',
PUNCT_SH__ = '$',
PUNCT_AMP = '&',
PUNCT_LPAR = '(',
PUNCT_RPAR = ')',
PUNCT_COLON = ':',
PUNCT_EQ = '=',
PUNCT_AT = '@',
PUNCT_LBRACKET = '[',
PUNCT_RBRACKET = ']',
PUNCT_LBRACE = '{',
PUNCT_PIPE = '|',
PUNCT_RBRACE = '}',
PUNCT_SPREAD = 0x2026, // spread operator (triple dot)
};


struct graphql_token {
struct list_node list;
unsigned int token_type;
unsigned int token_specific;
struct list_node node;
enum token_type_enum token_type;
char *token_string;
unsigned int source_line;
unsigned int source_column;
unsigned int source_offset;
unsigned int source_len;
void *data; // for application use
};

/* The lexer.
@@ -212,19 +268,24 @@ struct graphql_token {
* RETURN:
* GRAPHQL_SUCCESS or an error string.
*/
const char *graphql_lex(const char *input, const tal_t *ctx, struct list_head **tokens);
const char *graphql_lex(const tal_t *ctx, const char *input, struct list_head **tokens);

/* The parser.
* INPUTS:
* tokens - the list produced by the lexer
* doc - a variable to receive the resulting abstract syntax tree (AST)
* OPERATION:
* The token list is emptied during parsing, so far as the parsing
* succeeds. This allows the caller to inspect the line/char position
* of the next token (where the error likely is) and report that hint to
* the user in the form of an error message.
* RETURN:
* GRAPHQL_SUCCESS or an error string.
*/
const char *graphql_parse(struct list_head *tokens, struct graphql_executable_document **doc);

/* The lexer and parser in one function, for convenience. */
const char *graphql_lexparse(const char *input, const tal_t *ctx, struct list_head **tokens, struct graphql_executable_document **doc);
const char *graphql_lexparse(const tal_t *ctx, const char *input, struct list_head **tokens, struct graphql_executable_document **doc);

#endif

894 changes: 447 additions & 447 deletions ccan/graphql/test/run.c

Large diffs are not rendered by default.