forked from Gscienty/libgraphql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparser.c
37 lines (30 loc) · 813 Bytes
/
parser.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#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;
}