-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "parser.h" | ||
|
||
static int graphql_parser_init(graphql_parser_t *, const char *, int, int); | ||
|
||
int graphql_parse(const char *src, int no_loc, int no_src, graphql_ast_document_t *doc) | ||
{ | ||
int err; | ||
graphql_parser_t parser; | ||
err = graphql_parser_init(&parser, src, no_loc, no_src); | ||
if (err < 0) { | ||
return err; | ||
} | ||
|
||
// TODO | ||
|
||
return 0; | ||
} | ||
|
||
static int graphql_parser_init(graphql_parser_t *parser, const char *src, int no_loc, int no_src) | ||
{ | ||
int err; | ||
parser->src = src; | ||
parser->opt.no_loc = no_loc; | ||
parser->opt.no_src = no_src; | ||
parser->prev_end = 0; | ||
err = graphql_lex_init(&parser->lexer, src); | ||
if (err < 0) { | ||
return err; | ||
} | ||
err = parser->lexer.cb(&parser->lexer, &parser->tok, 0); | ||
if (err < 0) { | ||
return err; | ||
} | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef _LIBGRAPHQL_PARSER_H | ||
#define _LIBGRAPHQL_PARSER_H | ||
|
||
#include "lexer.h" | ||
#include "ast.h" | ||
|
||
typedef struct graphql_parse_options_s graphql_parse_options_t; | ||
struct graphql_parse_options_s { | ||
int no_loc; | ||
int no_src; | ||
}; | ||
|
||
typedef struct graphql_parser_s graphql_parser_t; | ||
struct graphql_parser_s { | ||
graphql_lexer_ctx_t lexer; | ||
const char *src; | ||
graphql_parse_options_t opt; | ||
int prev_end; | ||
graphql_token_t tok; | ||
}; | ||
|
||
int graphql_parse(const char *src, int no_loc, int no_src, graphql_ast_document_t *doc); | ||
|
||
#endif |